Project: Transfer Complex Variable Data Between Solutions

This scenario demonstrates how to transfer the data stored in a complex variable between a main project and an invoked workflow in another project. Because workflow input parameters and return types can be of simple types only, passing the data stored in complex variables requires a special approach.

Background

To transfer data stored in complex variables between solutions, the following JSON object methods are provided:

  • Load from Variable (new method), used to populate a JSON object with the contents of a complex variable.

  • Convert to Text (existing method), used to convert the contents of the JSON object to a text string.

  • Load from Text (existing method), used to populate a JSON object from a text string.

  • Write to Variable (new method), used to store the contents of the JSON object in a specified text variable

The chart below illustrates how these methods are used when transferring data from a main workflow to an invoked workflow. The same process can be used to transfer a result from the invoked workflow back to the main workflow.

Example Implementation

The workflow shown below is executed when a doctor presses a button "Display Ideal Body Weight" on a callout.

In step 1, the patient's information is retrieved from an Excel file to populate a complex variable called Patient_Info which is of the user-defined type Patient_Info. This complex variable has multiple properties, as shown below.

In step 2, the patient's information is passed to a robotic workflow that calculates the patient's ideal body weight. That workflow returns the calculated value which is then displayed in a callout in step 3.

The invoked robotic workflow requires the values of the Gender, Height, and Date of Birth properties from the Patient_Info variable to perform its calculations.

It is not possible to provide the whole Patient_Info variable as an input to the invoked parameter, as only simple variables can be used as input variables to invoked workflows.

The suggested solution approach is presented below.

Stage A: Prepare the project that includes the invoked workflow

Perform the step below in the project that includes the workflow that will be invoked.

  1. Configure the invoked workflow to receive one input parameter of type text.

Stage B: Invoke the workflow

Perform the steps below in the project that will invoke the other workflow.

  1. Create a JSON object. In this example it is called JSON_Obj_Out.

  2. Create a text variable. In this example it is called Text_Out.

    Note that use of this variable is optional and is shown here mainly for demonstration purposes. See the last step in this stage for more information.

  3. Use the JSON object's Load from Variable method to populate the JSON object from the contents of the Patient_Info variable.

  4. Store the contents of the JSON object in the text variable, using the Convert to Text method.

  5. Invoke the robotic workflow, passing the text variable as its required input.

    Note that this example uses the Text_Out text variable for demonstration purposes only. It is possible to avoid using this intermediate value and the Assign step, as shown below.

Stage C: Process the input parameter received

Perform the steps below in the project that includes the workflow that will be invoked.

  1. Create a user-defined type that includes properties for all the data that the invoked workflow needs.

    The names you give to the properties of the user-defined type in the invoked project must be identical to the names of the corresponding properties in the main project.

    You do not need to include all of the same properties as included in the user-defined type in the main project. You can choose to only include those properties that the invoked workflow needs.

  2. Create a variable of the user-defined type created.

    In this example, the calculation of the patient's ideal body weight only requires the patient's date of birth, height, and gender. A type of Patient_Data was created with these properties, and a variable called Patient_Data of that type was created, as shown below.

  3. Create a JSON object. In this example it is called JSON_Object_In.

  4. Populate the JSON object with the workflow's input parameter, using the JSON object's Load from Text method.

  5. Populate the complex variable with the data in the JSON object using the JSON object's Write to Variable method.

    The rest of the workflow can now read data from the relevant properties of the complex variable.

The table below illustrates how the values of the various variables are set when the main workflow is executed.

In the Main Project

Description

Variable Value

The complex variable is populated
The JSON object is populated from the complex variable using Load from Variable

(Value not displayed in debugger)

The text variable is populated from the JSON object using Convert to Text

In the Invoked Project

Description

Variable Value

The invoked workflow receives the input parameter as text
The JSON object is populated from the text input parameter received using Load from Text

(Value not displayed in debugger)

The complex variable is populated from the JSON object using Write to Variable.