Latest News

the latest news from our team

Get a single value of an array

Several situations have come up where people want to get only the first or last item in an array.

XML data source

Multiple values of the same element are imported to eFORMz as a variable array. These are the XML values in a BOL:

<bolshipfrom>Minisoft</bolshipfrom>
<bolshipfrom>1024 First Street</bolshipfrom>
<bolshipfrom/>
<bolshipfrom/>
<bolshipfrom>Snohomish WA 98290</bolshipfrom>
<bolshipfrom>United States</bolshipfrom>

And these values imported to eFORMz as an array:

Complete the following steps to get only the first value of this array:

1. In the Project window, right-click Variables > Add Variable > By position:


2. Enter a name for the variable and click OK. Do not change other fields.

3. Right click the new variable > Add Function > Set value.

4. Click Variable, select the XML variable, and then click OK.

The new variable contains the first value of the XML array:

Text data source

A common practice is to capture an entire area as a single variable, such as the ship to name and address. This variable is an array, and each line is an element of the array.

To capture only the first line as a variable, follow the same procedure described above–Create a variable and set its value to the multi-line variable.

Leave a Reply

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

*

code