General


Global variables is a feature that allows a user to define some data in the organization level. Global variables can be get and set in activities where some data is set, like "Set Data", and also via API methods GetGlobalVariable and SetGlobalVariable. They can be used also in Branch activities to change flow depending on global variable value.
Global variables are persistent. Their values are saved in DB table GlobalVariablesData (PTM). Change history can be found in another table - GlobalVariablesLog (HistoryServerDesign).


Global variable definition


In Setup, new General /Global variables tab is created to define global variables.


Global variable can be added and deleted using this screen. Variable can be of either simple or ValueSet type. Simple types can be Text, Money, Percentage, Count, DateTime, TimeSpan, and Flag. ValueSet variables can be of any ValueSet type defined in the system.
Each variable can have description and default value that should correspond to type - flag variables can cave default value True or False, Count default value should be integer number, etc.
Global variable definition contains also Authorized BP field. It doesn't mean that just this BP can use it. It affect just for permissions to set this variable for supervisors. Variable with no authorized BP can be set just by activity or by API when organization admin logged in. If organization has authorized BP defined, it means that supervisors of this BP can set this variable via SetGlobalVariable API as well.


Using global variables in activities

All activities that get or set data  can also get and set global variables.

Typical activity that can get or set global variables is Set Data:


Another typical usage of global variable is Branch:



It allow the user to change interaction flow according to value of some global variable.

Global variable can also be used in Add remark, Add to log, in all "by variable" activities such as Set demand by variable, and also in announce & collect activities:

 



Global variable API


Apart from activities, global variables can be got and set also using API. Two methods named GetGlobalVariable and SetGlobalVariable were added to the system API.


GetGlobalVariable


GetGlobalVariable method has one parameter - variable name. The parameter is optional, it it is empty, the method brings all variables in the system that have values, even default values.



The response is an array of global variable data with such fields as Variable Guid, variable name, property type, type, value, remark, changed by, and LastModifiedDatetime. Last three columns are defined if a variable was once set and has a value, otherwise they are empty. Value contains default if it was never set, or actual value from the last setting.


If "variable name" parameter is not empty, just one item for variable with name equal to parameter will be returned:

If variable name is wrong, error message is returned.

The method is available for all users - admins, supervisors, and agents.


SetGlobalVariable


SetGlobalVariable API method has three parameters - variable name, value, and remark. Remark is optional, two other parameters are required. Value should be in format appropriate for variable type - integer number for Count, number with decimal digit for Money, one of Value set elements for ValueSet, etc.

If variable name is wrong, if value doesn't correspond to value type, the method returns error.
This method is always available for organization admin. Supervisor also can run this method, but just for variables with "authorized BP" that is a business process the supervisor manages. This methos is not available for agents.


Example



This flow manages "Disaster recovery status" global variable named DRStatus. The variable is of type Flag and can be true or false. There is some BP or channel that informs user about current value of DRStatus variable and proposes to change it to the opposite one. The user can agree or disagree to change it.


There is Disaster Recovery manager - application that check if there is a disaster. It checks if there is a disaster by some timer. In case disaster is detected, it performs call to GetGlobalVariable API with parameter "DRStatus" and only if returned value is true, it will perform the recovery.

The flow for disaster recovery setting looks as follows:




  • No labels