# An unhandled exception (''$FBVariables' is undefined') occured in FinalBuilder7.exe &#91;1768&#93;

**URL:** https://www.finalbuilder.com/forums/t/an-unhandled-exception-fbvariables-is-undefined-occured-in-finalbuilder7-exe-91-1768-93/1952
**Category:** Discussion
**Created:** [February 23, 2012, 7:38am UTC](https://www.finalbuilder.com/forums/t/an-unhandled-exception-fbvariables-is-undefined-occured-in-finalbuilder7-exe-91-1768-93/1952 "2012-02-23T07:38:02Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [February 23, 2012, 7:38am UTC](https://www.finalbuilder.com/forums/t/an-unhandled-exception-fbvariables-is-undefined-occured-in-finalbuilder7-exe-91-1768-93/1952/1 "2012-02-23T07:38:02Z")

</div>

I am getting an error when attempting to use $FBVariables.

Here is the error message.An unhandled exception (''$FBVariables' is undefined') occured in FinalBuilder7.exe [1768]  
  
&nbsp;&nbsp;&nbsp; Error Executing script : BeforeAction  
&nbsp;&nbsp;&nbsp; Microsoft JScript runtime error  
&nbsp;&nbsp;&nbsp; '$FBVariables' is undefined  
&nbsp;&nbsp;&nbsp; Line : 2  
&nbsp;&nbsp;&nbsp; Char : 3  
&nbsp;&nbsp;&nbsp; Error in BeforeScript : JavaScript, This Action did not execute.  
  
I am using FinalBuilder 7.0.0.787.  
  
This error occurs in the BeforeAction javascript of the Build VS.Net Solution (Using MSBuild) action.

```
Here is the javascript. The error occurs on the yellow highlighted line below.function BeforeAction(Action, SkipAction) {
```

```
switch($FBVariables.GetVariable("BuildTarget")){ case "2": Action.OverrideTargetFramework = true; Action.TargetFramework = TVSDotNetTargetFx.fx20; break; case "3": Action.OverrideTargetFramework = true; Action.TargetFramework = TVSDotNetTargetFx.fx30; break;
```

```
case "3.5": Action.OverrideTargetFramework = true; Action.TargetFramework = TVSDotNetTargetFx.fx35; break; case "4": Action.OverrideTargetFramework = true; Action.TargetFramework = TVSDotNetTargetFx.fx40; break; }
```

}

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [February 23, 2012, 9:54am UTC](https://www.finalbuilder.com/forums/t/an-unhandled-exception-fbvariables-is-undefined-occured-in-finalbuilder7-exe-91-1768-93/1952/2 "2012-02-23T09:54:43Z")

</div>

Drop the $ before FBVariables, it’s not needed for javascript.

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [February 24, 2012, 12:02pm UTC](https://www.finalbuilder.com/forums/t/an-unhandled-exception-fbvariables-is-undefined-occured-in-finalbuilder7-exe-91-1768-93/1952/3 "2012-02-24T12:02:29Z")

</div>

Thanks, I will test it tomorrow (its 6:02 PM Eastern Time). I will respond with results tomorrow.

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [February 24, 2012, 2:53am UTC](https://www.finalbuilder.com/forums/t/an-unhandled-exception-fbvariables-is-undefined-occured-in-finalbuilder7-exe-91-1768-93/1952/4 "2012-02-24T02:53:27Z")

</div>

Now I get the same undefined error but now it is with this variable ‘TVSDotNetTargetFx’ same code block mentioned above.

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [February 25, 2012, 12:17pm UTC](https://www.finalbuilder.com/forums/t/an-unhandled-exception-fbvariables-is-undefined-occured-in-finalbuilder7-exe-91-1768-93/1952/5 "2012-02-25T12:17:45Z")

</div>

Ah sorry, I didn’t look past the $FBVariables, try this :   
  
 switch(FBVariables.BuildTarget)   
 {   
 case “2”:   
 Action.OverrideSDKDefault = true;   
 Action.SDKVersion = “v2.0”;   
 break;   
 case “3”:   
 Action.OverrideSDKDefault = true;   
 Action.SDKVersion = “v3.0”;   
 break;   
 case “3.5”:   
 Action.OverrideSDKDefault = true;   
 Action.SDKVersion = “v3.5”;   
 break;   
  
 case “4”:   
 Action.OverrideSDKDefault = true;   
 Action.SDKVersion = “v4.0”;   
 break;   
 }

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [February 25, 2012, 3:32am UTC](https://www.finalbuilder.com/forums/t/an-unhandled-exception-fbvariables-is-undefined-occured-in-finalbuilder7-exe-91-1768-93/1952/6 "2012-02-25T03:32:47Z")

</div>

Thanks I will test this Monday morning US Eastern Time. What other posts, etc. Are good to look at to learn more about before action/ after action scripting?
