Salesforce

Context Variables (Magic xpi 4.13)

« Go Back

Information

 
Created BySalesforce Service User
Approval Process StatusPublished
Objective
Description

Context Variables (Magic xpi 4.13)

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 utility 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:

Variable

Description

Type

Length

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

1000

C.sys.RemoteUser

The user name from an external call. It is used with HTTP triggers.

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

1000

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 Logging section of the component's Properties pane. This is overridden by the G.sys.ComponentLogging variable setting.

Boolean

1

C.sys.InvokingBPName

The business process where the last error occurred or the Invoke Flow was called.

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.

Make sure that the <Magic xpi>/scripts/config/mgreq.ini file's HttpVars entry is enabled and that it contains MG_POST_BODY.

BLOB

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

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:

  • Component XML interfaces are always based on the C.UserXML variable.

  • All messaging triggers use the C.UserBlob variable for message content.

To create context variables:

  1. Under the Solution Explorer's Repositories folder, double-click Context Variables to open the Context Variables repository. Alternatively, you can open the Context Variables repository by pressing SHIFT+F4.

  2. Click Add to create a new line in the list.

  3. Define the variable's properties. For a full description of these properties, click here.

  4. When you have entered the relevant properties, click Save.

  5. You can remove variables by parking on the relevant line and clicking Delete, followed by Save. Before deleting an entry, you should make sure that it is not used in other places in your project. You can do this by running the Find Reference utility.

You cannot add duplicate names to the Context Variables repository, and the name field cannot be left empty.

Related Topics

Reference
Attachment 
Attachment