# Javascript BeforeAction Context not found

**URL:** https://www.finalbuilder.com/forums/t/javascript-beforeaction-context-not-found/1416
**Category:** Discussion
**Created:** [January 4, 2010, 11:10am UTC](https://www.finalbuilder.com/forums/t/javascript-beforeaction-context-not-found/1416 "2010-01-04T11:10:25Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mozenda](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/mozenda/32/92_2.png) [@mozenda](https://www.finalbuilder.com/forums/u/mozenda)
#### Post date: [January 4, 2010, 11:10am UTC](https://www.finalbuilder.com/forums/t/javascript-beforeaction-context-not-found/1416/1 "2010-01-04T11:10:25Z")

</div>

&nbsp;We have the following snippet of javascript executing in the BeforeAction event of an action:

&nbsp;

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?

&nbsp;

-Corey

&nbsp;

---

<div class="post-metadata">

### Author: ![paulsamways](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/p/e8c25b/32.png) [@paulsamways](https://www.finalbuilder.com/forums/u/paulsamways)
#### Post date: [January 5, 2010, 1:03am UTC](https://www.finalbuilder.com/forums/t/javascript-beforeaction-context-not-found/1416/2 "2010-01-05T01:03:35Z")

</div>

Hi Corey,   
  
 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.   
  
 Regards,   
 Paul.
