show / hide menu

How to use loop rules in the form

How to use loop rules in the form

Step 1 : Create a variable ‘Vrow’ which is used to count the loop. Click on ‘Create variable’ Option  under Rule Picker  From the left side of the Rule tab.

Figure 1

Step 2 : Enter the Variable Name and click on ‘Save Variable’ button and after saving click on ‘Close’ button.

Figure 2

Step 3 : Initialize variable ‘vRow’ by giving ‘1’ as its value. After each iteration the value of ‘vRow’ will be incremented by one .

Figure 3

Step  4 : Create a sub-rule ‘On_GenerateValue_1’ for  defining the loop , as the loop contain a set of action which is executed repeatedly and should be separated from the initialization of ‘vRow’.

Figure 4

Step  5 : Define the loop . A loop contains a condition, set of action to be repeated , increment operation .

  • Define a Condition  such that iteration occurs only when this condition is satisfied else exit from the loop. for example here we take the total row count of grid by ‘DGTest.TotalRowCount’ command  and will check if its value is greater than the value in vRow. After each iteration the vRow Value will increase by one . When vRow value become greater than TotalRowCount, the loop will exit.
Figure 5

Define the set of action to be repeated. For example here ‘GridGetValue(DGTest,vRow,1)’ will give the value in that particular row  ,which matches with the value in vRow. This value is summed up and stored into a text control named ‘txtTotalValue’.

Figure 6

Increment the value of variable ‘ vRow’  by one.

Figure 7

To continue the iteration call the loop rule by using RunRule function. For example we use ‘RunRule(On_GenerateValue.On_GenerateValue_1)’ . Here  ‘On_GenerateValue ‘ is the main rule name and ‘ On_GenerateValue_1’ is the sub-rule name.

Figure 8

Figure 9 shows the Loop rule.

Figure 9