{"id":7417,"date":"2019-04-29T23:05:42","date_gmt":"2019-04-29T23:05:42","guid":{"rendered":"https:\/\/alt2.minisoft.com\/support\/?p=7417"},"modified":"2019-04-29T23:05:45","modified_gmt":"2019-04-29T23:05:45","slug":"get-a-single-value-of-an-array","status":"publish","type":"post","link":"https:\/\/minisoft.com\/support\/get-a-single-value-of-an-array\/","title":{"rendered":"Get a single value of an array"},"content":{"rendered":"\n<p>Several situations have come up where people want to get only the first or last item in an array. <\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>XML data source<\/strong><\/p>\n\n\n\n<p>Multiple values of the same element are imported to eFORMz as a variable array. These are the XML values in a BOL:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;bolshipfrom>Minisoft&lt;\/bolshipfrom>\n&lt;bolshipfrom>1024 First Street&lt;\/bolshipfrom>\n&lt;bolshipfrom\/>\n&lt;bolshipfrom\/>\n&lt;bolshipfrom>Snohomish WA 98290&lt;\/bolshipfrom>\n&lt;bolshipfrom>United States&lt;\/bolshipfrom><\/code><\/pre>\n\n\n\n<p>And these values imported to eFORMz as an array:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" loading=\"lazy\" width=\"299\" height=\"69\" src=\"https:\/\/alt2.minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single1.jpg\" alt=\"\" class=\"wp-image-7418\" srcset=\"https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single1.jpg 299w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single1-150x35.jpg 150w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single1-250x58.jpg 250w\" sizes=\"(max-width: 299px) 100vw, 299px\" \/><\/figure><\/div>\n\n\n\n<p>Complete the following steps to get only the first value of this array:<\/p>\n\n\n\n<p>1. In the Project window, right-click Variables &gt; Add Variable &gt; By position: <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" loading=\"lazy\" width=\"450\" height=\"205\" src=\"https:\/\/alt2.minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single2.jpg\" alt=\"\" class=\"wp-image-7420\" srcset=\"https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single2.jpg 450w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single2-300x137.jpg 300w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single2-150x68.jpg 150w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single2-250x114.jpg 250w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single2-395x180.jpg 395w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><figcaption><br><\/figcaption><\/figure><\/div>\n\n\n\n<p>2. Enter a name for the variable and click OK. Do not change other fields.<\/p>\n\n\n\n<p>3. Right click the new variable &gt; Add Function &gt; Set value.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" loading=\"lazy\" width=\"584\" height=\"145\" src=\"https:\/\/alt2.minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single3-1.jpg\" alt=\"\" class=\"wp-image-7422\" srcset=\"https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single3-1.jpg 584w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single3-1-300x74.jpg 300w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single3-1-150x37.jpg 150w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single3-1-250x62.jpg 250w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single3-1-550x137.jpg 550w\" sizes=\"(max-width: 584px) 100vw, 584px\" \/><\/figure><\/div>\n\n\n\n<p>4. Click Variable, select the XML variable, and then click OK.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" loading=\"lazy\" width=\"409\" height=\"249\" src=\"https:\/\/alt2.minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single4.jpg\" alt=\"\" class=\"wp-image-7423\" srcset=\"https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single4.jpg 409w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single4-300x183.jpg 300w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single4-150x91.jpg 150w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single4-250x152.jpg 250w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single4-296x180.jpg 296w\" sizes=\"(max-width: 409px) 100vw, 409px\" \/><\/figure><\/div>\n\n\n\n<p>The new variable contains the first value of the XML array:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"294\" height=\"82\" src=\"https:\/\/alt2.minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single5.jpg\" alt=\"\" class=\"wp-image-7424\" srcset=\"https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single5.jpg 294w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single5-150x42.jpg 150w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single5-250x70.jpg 250w\" sizes=\"(max-width: 294px) 100vw, 294px\" \/><\/figure>\n\n\n\n<p><strong>Text data source<\/strong><\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>To capture only the first line as a variable, follow the same procedure described above&#8211;Create a variable and set its value to the multi-line variable.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"518\" height=\"151\" src=\"https:\/\/alt2.minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single6.jpg\" alt=\"\" class=\"wp-image-7427\" srcset=\"https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single6.jpg 518w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single6-300x87.jpg 300w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single6-150x44.jpg 150w, https:\/\/minisoft.com\/support\/wp-content\/uploads\/2019\/04\/Single6-250x73.jpg 250w\" sizes=\"(max-width: 518px) 100vw, 518px\" \/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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: And these values imported to eFORMz as an array: Complete the [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/minisoft.com\/support\/wp-json\/wp\/v2\/posts\/7417"}],"collection":[{"href":"https:\/\/minisoft.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/minisoft.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/minisoft.com\/support\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/minisoft.com\/support\/wp-json\/wp\/v2\/comments?post=7417"}],"version-history":[{"count":3,"href":"https:\/\/minisoft.com\/support\/wp-json\/wp\/v2\/posts\/7417\/revisions"}],"predecessor-version":[{"id":7428,"href":"https:\/\/minisoft.com\/support\/wp-json\/wp\/v2\/posts\/7417\/revisions\/7428"}],"wp:attachment":[{"href":"https:\/\/minisoft.com\/support\/wp-json\/wp\/v2\/media?parent=7417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/minisoft.com\/support\/wp-json\/wp\/v2\/categories?post=7417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/minisoft.com\/support\/wp-json\/wp\/v2\/tags?post=7417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}