Use XML Variable of Type XML Forms Data Grid
- Last UpdatedJun 10, 2024
- 6 minute read
The XML Forms Data Grid variable usage can be demonstrated using the following two scenarios:
-
Create "Xml Forms Data Grid" type Xml Variable and use it in a workflow to iterate through row selections done in the Data Grid.
-
Use "Xml Forms Data Grid" type Xml Variable to change/add row selections in a Data Grid control using Workflow.
Let us consider a typical Work Order – Job manufacturing process scenario. In a manufacturing process, a work order is a collection of jobs that produce an item. A job is a list of steps or procedures that is executed to produce an item or a version of an item. The list of steps can be grouped together into Step Groups. Multiple jobs can be performed to produce a single item.
Prerequisites
-
AVEVA Work Tasks Form with two Data Grids. One Data Grid will be showing the Work Order and Jobs details and the other would show the Job Step details. When the user selects a Job in the Work Order and Jobs grid, the Job Steps grid will be populated with the relevant Job Steps.
The grid selection information is stored in the XML nodes mapped to the Grid Control. To extract the required values and use it within workflows, we need to create XML variables of type XML Forms Data Grid. -
This form is associated to a new Workflow. The XML variable SFFormData will be added to the XML Variable collection. (Form XML variable can also be created without association, i.e. by selecting the corresponding Form from the XML Variable interface).

Scenario 1: Create Xml Forms Data Grid type Xml Variable and use it in a workflow to iterate through selections done in the Data Grid
-
Create an XML variable of type XML Forms Data Grid as shown below for Job Steps Grid. Select JobStepsGrid XML Node which is mapped to the Job Steps Grid Configuration. (This will contain the complete selection information of the Data Grid once the form is submitted.)

-
As the selected job can have multiple steps, we need an XML Iterator variable to iterate through the multiple steps selected in the Job Steps Grid. Create an XML Iterator variable 'LoopJobSteps' with repeating node(Node Select) as JobStepLookup.
I
Note: The XML Iterator variable is created to iterate through the multiple selections. To get more information on the selections in the parent hierarchy levels, an XML Iterator needs to be created for the parent node (which is repeating) also.
For example, if we have to loop through the multiple selections of Work Order we need to create Iterator variable with the repeating node as 'WorkOrderLookup'.
-
Add a ForEach Loop activity. Set its XML Iterator property with the Iterator variable created above.

-
Add an Information activity to display the selections made. Set its Body property as shown below:

-
Design the workflow as shown below:

-
Publish and Test Run the workflow.
-
Select rows from Work Order Jobs Grid in the form. The Job Steps Grid gets populated with the steps for the selected job. Select the Steps and then click Finish.

-
Information is sent with Step details of the selected job.


Scenario 2: Use Xml Forms Data Grid type Xml Variable to change/add row selections in a Data Grid control using Workflow.
The Forms Data Grid XML variable can also be used to add/modify the row selections done in a Data Grid control. The below scenario explains how to add a row selection to the existing row selections using workflows.
-
Create an XML Forms Data Grid Variable for the Jobs Step Grid Configuration as shown below:

-
Create an XML Iterator variable to iterate through the Jobs Steps for the selected job.

The form instance XML generated for the form with a Job Step selected will be as given below. [However, note that the XML generated will be in the encoded format in the Form instance XML].

<Grid>
<Data>
<JobStepsLookup>
<wo_id><![CDATA[100]]></wo_id>
<oper_id><![CDATA[100-PMX]]></oper_id>
<seq_no><![CDATA[0]]></seq_no>
<step_no><![CDATA[1]]></step_no>
<step_seq><![CDATA[1]]></step_seq>
<step_name><![CDATA[Add ingredients]]></step_name>
</JobStepsLookup>
</Data>
</Grid>
To add another row selection using workflows, another XML node has to be created for the JobStepsLookup node (which is the repeating node). If another node is added, the XML will be generated as shown below:
<Grid>
<Data>
<JobStepsLookup>
<wo_id><![CDATA[100]]></wo_id>
<oper_id><![CDATA[100-PMX]]></oper_id>
<seq_no><![CDATA[0]]></seq_no>
<step_no><![CDATA[1]]></step_no>
<step_seq><![CDATA[1]]></step_seq>
<step_name><![CDATA[Add ingredients]]></step_name>
</JobStepsLookup>
<JobStepsLookup>
<wo_id><![CDATA[100]]></wo_id>
<oper_id><![CDATA[100-PMX]]></oper_id>
<seq_no><![CDATA[0]]></seq_no>
<step_no><![CDATA[3]]></step_no>
<step_seq><![CDATA[3]]></step_seq>
<step_name><![CDATA[Run Mixer]]></step_name>
</JobStepsLookup>
</Data>
</Grid>

To achieve this, XML Navigator activity is being used in this scenario.
-
Add an XML Navigator activity to add a new row selection to the JobSteps grid. Set the properties as shown below. Please note that Create New Node property is set as Yes.

Note: To add selections at multiple hierarchy levels, an Iterator variable has to be created at the parent levels with their corresponding repeating nodes.
-
To set the value for the row selection an Update Variable activity is used. This activity needs to update the value to the Value field of the lookup data source of the Grid Configuration.
Here the Value column for the Jobs Step Grid Configuration is: step_no.

Note: This update does not update or modify any data to the data source lookup configured for the Data Grid Control.
-
Design the workflow as shown below:

-
Publish and Test Run the workflow.
-
Select rows from Work Order Jobs Grid in the form. The Job Steps Grid gets populated with the steps for the selected job. Select the Steps and then click Finish.

-
Once the workflow execution is complete, information is sent with the updated Job Step selection details.

Note: To modify an existing selection, go to the specific node and update the Value field of the lookup data source. If a definite node is not specified for updating the selection, then by default the first selection is modified and updated.