Context Variables (Magic xpi 3.x)
Context variables are created when a new context (thread) is launched. They are valid as long as the context is alive, even if it spans several flows before it concludes its activity. The context variable's definition is inherited by all the flows in the project. They are defined once for all the flows in the project. Context variables are used to manage flow logic and transfer data between components for every flow in a project.
Best Practices
|
|
Use the Data Mapper to manipulate data that was invoked from a previous flow using the call flow option in the Destination.
|
|
|
Use sub-processes to validate data that was received by a main process.
|
When you define a context variable, it is automatically created in each flow. You can assign values to the context variables using the Flow Data Service or the Data Mapper. If you make changes to these values, the changes apply only to that specific linear process. This is also true when you have parallel flows in your project, as the context variables have values that are unique to the linear process in which they are defined.
The predefined context variables are:
|
|
|
|
C.sys.ErrorCode
|
The current error code, this variable is cleared upon entering a step, and is set when an error occurs during step operation. This variable can only be used in the next step condition. The ErrorCode is also saved in the C.sys.LastErrorCode and this value is not cleared. For more information about this variable and .NET, click here.
|
Numeric
|
12
|
C.sys.ErrorDescription
|
A description of the error. This variable is cleared upon entering a step, and is set when an error occurs during step operation. This variable can only be used in the next step condition. The ErrorDescription is also saved in the C.sys.LastErrorDescription and this value is not cleared. For more information about this variable and .NET, click here.
|
Alpha
|
260
|
C.sys.RemoteUser
|
The user name from an external call. It is used with HTTP triggers.
|
Alpha
|
30
|
C.UserString
|
Used for passing alpha-numeric information between components in flows.
|
Alpha
|
1000
|
C.UserCode
|
Used for passing numeric-only information between components in flows.
|
Numeric
|
12
|
C.UserBlob
|
Used for passing undefined types of information between components in flows.
|
BLOB
|
|
C.UserXML
|
Used internally to pass the configuration XML to the component when an XML interface is used.
|
BLOB
|
|
C.HTTP_Body
|
The body of the HTTP request.
|
BLOB
|
|
C.sys.InvokingBPName
|
The business process where the last error occurred or the Invoke Flow was called.
Since version: V3.1 SP1
|
Alpha
|
30
|
C.sys.InvokingFlowName
|
The Flow Name where the last error occurred or the Invoke Flow was called.
|
Alpha
|
30
|
C.sys.InvokingComponentName
|
The Component Name where the last error occurred or the Invoke Flow was called.
|
Alpha
|
30
|
C.sys.LastErrorFlowName
|
The name of the flow where the last error occurred.
|
Alpha
|
30
|
C.sys.LastErrorStepName
|
The name of the step where the last error occurred.
|
Alpha
|
30
|
C.sys.LastErrorInfo
|
Detailed information about the error. When the Source or Destination type is Database, the SQL statement that was sent to the database is included in the error information. When the Source or Destination type is XML, the validation errors are included in the error information.
|
BLOB
|
|
C.sys.LastErrorCode
|
The last error code. This variable is set when a new error occurs. The error code is kept in the variable until a new error code overrides it.
|
Numeric
|
12
|
C.sys.LastStepID
|
The Step ID of the last executed step. This variable is set after the execution of each component.
|
Numeric
|
12
|
C.sys.LastFlowID
|
The Flow ID of the last executed step. This variable is set after the execution of each component.
|
Numeric
|
12
|
C.sys.LastErrorDescription
|
A description of the last error.
|
Alpha
|
260
|
C.sys.LastErrorComponentType
|
The type of component where the last error occurred.
This variable is useful, because in order to raise an error, you need to know in which component type the error occurred, as well as the error code (C.sys.ErrorCode). If both variables are updated, the matching error will be written in the Monitor, and the error behavior will take place.
|
Numeric
|
12
|
C.sys.LastTriggerName
|
This variable holds the component name that triggered the flow. This variable will be updated with every trigger invocation, and can be used by the flow to check which trigger was operated.
|
Alpha
|
30
|
C.sys.ContextLogging
|
A flow level (context) variable to dynamically control the component logging. When set to True (the default), logging behaves as defined in the component's Logging tab. Overridden by the G.sys.ComponentLogging variable setting.
|
Boolean
|
1
|
Note:
|
The C.UserString, C.UserBlob, and C.UserXML variables (above) are default variables that are defined in components, and can be changed to any user-defined variable of the same type.
There are two exceptions to this:
|
|
To create context variables:
-
From the Project menu, click Variables. This opens the Project Variables dialog box. Click the Context Variable tab to define the context variables for the project. You can also define context variables by selecting Variables from the Flow menu or by pressing Ctrl+L. This opens the Variables for Flow dialog box. Select the Context Variable tab.
-
Click New to bring cursor focus to the Name field of the first empty variable entry in the list.
-
Define the variable's properties. For a full description of these properties, click here.
-
When you have entered the relevant properties, click OK to add the variable and to close the dialog box.
-
You can remove variables by clicking Delete.
-
Clicking Cancel closes the dialog box without saving your newly added variables.
Flow Variables
Business Process Variables
Global Variables