For this week, I want to cover one of the new features in SmartConnect 2010: Global Variables. Now, if you have done scripting in SmartConnect before, you may have noticed that global variables have been in SmartConnect for a while now. However, now we can actually create new global variables and assign default values to them as needed.

To create new variables we need to go through Tools -> SmartConnect -> Setup. On that window hit the Variables button to bring up the window where we can create new variables, remove existing ones, or set default values.

If you set a default value for a variable, it will assign this value to the variable as soon as it is initialized in a map rather than leaving it as a null value. This can be useful if you are storing something that you won’t normally change (like an email address) or if your scripts have issues with null values.

You can set variable defaults per map that override the overall defaults if you want for the specific map. This can be done from the Map Setup screen by going to the Options -> Tasks button. On the Maintain Tasks window, Global Variable Defaults should be selected on the left, and then any of the variable defaults can be changed.

If you override the default value on the map, the variable name will change its font color to show that the variable has a different default value from the overall setup.

These global variables can be used in any scripts (calculated fields, restrictions, tasks scripts, etc) to store and pass data between different scripts on the same map. They can be used in other tasks as well; for example, using global variables as the email addresses and the body of the email in the email task.