Latest News

the latest news from our team

Retrieving One Item From a Group

Often, there is one item within an array that needs to be utilized separately from the other values in that group. There are several ways to accomplish this in eFORMz, depending on the particular situation. To follow along with the tutorials below, download the sample files here:

http://support.minisoft.com/wordpress/wp-content/uploads/2017/11/ProjectUseFirst.zip

First Item From a List
Current Repeat Index (Not the First or Last Item)
Choose One Of (Not the First or Last Item)
Last Item From a List

First Item From a List

There are certain situations, especially when running an SQL query to establish a variable value, where it’s necessary to create a variable that contains only the first value from a group of values. In other words, it’s necessary to retrieve the first item from a list and set a variable with that value. This can be done using conditional logic and a Set Variable procedure in the following manner:

1. Right click ‘lines’ and select Add Variable.

2. The Variable dialog box displays. Select OK to continue.

3. In the Project Window, right click the form and select Add Variable > By position. Enter ‘line1’ in the Name field and select OK.

4. Right click the ‘line1’ variable from the Project Window and select Add Pre-condition Procedure > Set Variable. Enter ‘FirstFirst’ in the Name field. From the Use variable field, select the ‘lines’ variable created earlier. Select OK.

5. The Set Variable Action dialog box displays. Select ‘line1’ from the Variable drop-down menu. Select OK.

6. Right click the ‘FirstFirst’ procedure and select Add AND Condition > Is not equal to. The Data Condition dialog box displays. From the Of variable drop-down menu, select the ‘lines’ variable created earlier. Leave the field below ‘Is not equal to’ blank. Select OK to continue.

7. Right click the ‘FirstFirst’ procedure and select Add AND Condition > Is equal to. The Data Condition dialog box displays. From the Of variable drop-down menu, select the ‘line1’ variable created earlier. Leave the field below ‘Is equal to’ blank. Select OK to continue.

NOTE: Using the (line is equal to “”) limits the selection to the first valid value. Without it, the last value would be returned. The second condition (lines is not equal to “”) can be replaced with any number of comparison operators to select the value needed.

View the Variables Window to see the results:


Current Repeat Index (Not the First or Last Item)

If it’s necessary to retrieve a specific line number from a list, such as the second line for example, the Current Repeat Index system variable can be used. For an in-depth tutorial and a sample eFORMz project, visit the following post: Current Repeat Index.

Choose One Of (Not the First or Last Item)

If it’s necessary to retrieve a specific line number from a list, such as the second line for example, the Choose One Of function can be used. For an in-depth tutorial and a sample eFORMz project, visit the following post: Choose One Of.

Last Item From a List

Finally, it may be necessary to create a variable that contains only the last value from an array. This is particularly useful in situations where the last value in an array is a total of the previous values. In other words, it’s necessary to retrieve the last item from a list and set a variable with that value. This can be done using conditional logic and a Set Variable procedure in the following manner:

1. Right click ‘lines’ and select Add Variable.

2. The Variable dialog box displays. Select OK to continue.

3. In the Project Window, right click the form and select Add Variable > By position. Enter ‘lastline’ in the Name field and select OK.

4. Right click the ‘lastline’ variable from the Project Window and select Add Pre-condition Procedure > Set Variable. Enter ‘LastNotEmpty’ in the Name field. From the Use variable field, select the ‘lines’ variable created earlier. Select OK.

5. The Set Variable Action dialog box displays. Select ‘lastline’ from the Variable drop-down menu. Select OK.

6. Right click the ‘LastNotEmpty’ procedure and select Add AND Condition > Is not equal to. The Data Condition dialog box displays. From the Of variable drop-down menu, select the ‘lines’ variable created earlier. Leave the field below ‘Is not equal to’ blank. Select OK to continue.

View the Variables Window to see the results:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

code