Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In some workflows the workflows, the solution requires handing over a variable from one object to another. This brief tutorial article helps you understand the general concept of sharing variables within in IWS.

...

How to share variable from one task to another?

Let's assume you have two objects on the worksheet, object A and object B.

Image Removed
To make a variable pass from object A to object B, you should place this variable into object A's OutParams and then code for Object B to allow it to receive the variable and process it.

Image Removed
Object A's OutParams are set in its Properties box.
The variable should be placed into the box without any specific symbols, as shown here:

Image Removed

...

Panel
/53CAparam_TASK_my_translator_var_name/53CA

Let's take a closer look at this name format:
/53CA is the IWS code for the ":" (colon) character, so this expression stands for:

Panel
:param_TASK_my_translator_var_name:

Image Removed

Warning
iconfalse
Don't forget to replace ":" with /53CA when you paste the code into IWS.

Example of use: Condition to Execute.

back to tophave a look at the following example with two translators: shared_var_test_1 and shared_var_test_2. We want to share a variable (called variableA) from one translator to another.

To do that, three steps have to be taken

Step 1: Declare the variable as "output variable" in the source shape

This is done simply by typing the variable name (or comma-separated list of names) in the OutParams property of the source shape:

...

Step 2. Instruct the target shape to receive this new variable as input.

Click on the second task and in the CustomCMParams property set the name of the variable in the first column.

It does not have to be same variableA. You can use another alias for the target shape.

In the second column you should use the following construct:

Code Block
EXPR#:param_TASK_[name_of_task]_[original_name_of_shared_parameter]:

...

EXPR#:param_TASK_ is a required prefix. [name_of_task] is the name of the task where shared variable was created (shared_var_test_1 in our example). And variableA is the original name of the shared variable.

Info

There are three default variables generated by each shape: :TASK_[name_of_task]_STATUS:, :TASK_[name_of_task]_CORRID: and  :TASK_[name_of_task]_SEVERITYCODE: . Such variables do not require 'param_' prefix in front of them.

Final expression for our example:

Code Block
EXPR#:param_TASK_shared_var_test_1_variableA: 

...

Step 3. In the source shape, make the variable visible to the whole workflow.

This step differs depending on the type of source shape. Expand corresponding link below to see specific details

Expand
titleIn case of streaming translator (click to expand):

Drop the Code shape from left panel in ADVANCED group and set value of the Code shape as 

Code Block
:varTaskParams: := :varTaskParams: + 'variableA;' + :variableA: + '!'

If you need to share more variables you can add them to the Code shape using syntax variable_name;variable_value!. For example, if we have another variable count to share, the Code shape value is set like this:

Code Block
:varTaskParams: := :varTaskParams: + 'variableA;' + :variableA: + '!' + 'count;' + :count: + '!'

Your final picture should look like this

Expand
titleIn case of transform translator (click to expand):

Step A:  Drop a Variable shape onto the worksheet. It represents the variable you are going to share. Drop a Call Include shape from the left panel in ADVANCED group and click the Browse button next to the File property in the right panel

Variable in WorkflowImage Added

../eagle_ml-2-0_cm/w_config.inc

File Properties screenImage Added

Or, click the "ellipsis" button to select the file from the open dialog.

Browse windowImage Added

Step C: Drop the Code shape from left panel in group ADVANCED after the variable box and set value of the Code shape as

Code Block
languagetext
:CorrelationId: := SubString(:FILE_NAME:, Find(:FILE_NAME:, '-', 0, 2) + 1); :CorrelationId: := SubString(:CorrelationId:, 0, Find(:CorrelationId:, '_'));
Example of Shared Variables between Objects in WorkflowImage Added

Step D: Drop a Call Include shape from the Advanced section of the toolbox, and type the following text in its File property:

../eagle_ml-2-0_cm/get_w_state.inc

Properties dialogImage Added

Or, click the "ellipsis" button to select the file from the open dialog.

Browse windowImage Added

Step E: Drop another Code shape and set its value as:

Info

If you need to share more variables you can add them to the Code shape using variable_name;variable_value! syntax. For example, if we have another variable count to share, then the Code shape value will be as follows

Code Block
languagetext
IF (find(:varTaskParams:, 'variableA;') = -1) then :varTaskParams: := :varTaskParams: + 'variableA;' + :variableA: + '!';

Step F: Drop the second Call Include shape and type or select  file ../eagle_ml-2-0_cm/upd_w_state.inc

Browse windowImage Added

after all these additions you should have something similar to this:

image-20240725-190019.pngImage Added

To verify that new variables are passed to the target shape, run your workflow and check the Control Message tab in the Monitoring Tool.

You should be able to see your new variables as input parameters in the RTR:

...