Using Set Fields with temporary tree nodes
This section describes various ways to use the Set Fields action with temporary tree nodes.
Adding the last leaf node
To insert the last leaf node in a selected branch, you need to know the number of leaf nodes represented by the branch. To retrieve this information, use the SELECTEDROWCOUNT function with the Set Fields action.
For example, if the Italian node is selected in the following figure, this function returns the number of table rows in the underlying form represented by that branch, which is 2. To insert a row as the last leaf node in the Italian branch, you would run PERFORM-ACTION-TABLE-ADD-ROW on the Italian branch for a row index that is greater than 2.
On Italian branch, SELECTEDROWCOUNT returns 2
For information about using functions with the Set Fields action, see Defining-Set-Fields-actions-to-assign-values-based-on-conditions. For information about PERFORM-ACTION-TABLE-ADD-ROW, see Using-Run-Process-and-PROCESS-commands.
Adding data to empty nodes
When you use the PERFORM-ACTION-TABLE-ADD-ROW command to add an empty node to a tree view table, the values of the subsequent Set Fields action determine the final position of the node.
For example, suppose an empty node is added to index 3 of the tree view table in the following figure.
Empty node added to row index 3 of tree view table
The values in the subsequent Set Fields action might leave the new node in the same place, group it under the preceding parent node, or group it under the following parent node. For example, see the following figure.
Results of Set Fields action on row index 3
In each case, before performing the Set Fields action, you must select the empty node.
Set Fields does not trigger a re-sort of the underlying data set. Thus, to avoid displaying duplicate tree nodes, design your workflow with care. For example, the duplicate node in the following figure was created by inserting an empty node at index 1 and setting the node values to ["Japanese", "Ramen"].
Duplicate nodes produced by poorly designed workflow
Selecting a leaf node before running Set Fields
Suppose a Set Fields action is created to set the value of the first column field (corresponding to Italian and Japanese) to "French" in the tree in the following figure. Before the Set Fields action is performed, the Pizza leaf node is selected (see the "Before" tree). This selection causes Set Fields to set the value of the first column in row index 2. The "After" tree illustrates the result.
Set Fields action on leaf node
Selecting a parent node before running Set Fields
If a node in a tree view table represents multiple values in the underlying data set, the Set Fields action is triggered on the first value only. If you perform a Set Fields action to change the value of a parent node, only the first (primary) leaf node under the parent is affected.
For example, suppose a Set Fields action is created to set the value of the first column field (corresponding to Italian and Japanese) to "French" in the tree in the following figure. Before the action is performed, Italian is selected (see the "Before" tree). This selection causes Set Fields to change the value of only the first leaf node in the Italian branch, not all the leaf nodes in the branch. The "After" tree illustrates the result.
Set Fields action to parent node