We have the following snippet of javascript executing in the BeforeAction event of an action:
var fileName = Context.GetVariable("WebDeployment.FileName"); var id = fileName.replace(".", ""); Context.SetVariable("WebDeployment.ID", id);
However, when the action executes, we get the following error:
Error Executing script : BeforeAction Microsoft JScript runtime error 'Context' is undefined Line : 1 Char : 1 Error in BeforeScript : JavaScript, This Action did not execute.
How do we get and set FinalBuilder variables using javascript?
FinalBuilder Variables are accessed from script as if they were defined in current variable scope, for example:
If ‘Foo’ was a variable defined in FinalBuilder then in script you would use:
Foo = Foo.replace(".", “”);
Unfortunately though, because you are using dots in the variable name it breaks this functionality, as it will try to access the FileName field on the WebDeployment object. You’ll need to remove the dots for this to work.
If the above script is the only script you want to execute then you can use the String Replace action instead of script.