{"id":845,"date":"2023-03-09T17:05:17","date_gmt":"2023-03-09T14:05:17","guid":{"rendered":"https:\/\/docs.unibell.ru\/?page_id=845"},"modified":"2025-02-07T09:25:04","modified_gmt":"2025-02-07T06:25:04","slug":"%d0%bf%d0%be%d0%b8%d1%81%d0%ba-%d0%bf%d0%b5%d1%80%d0%b5%d0%bc%d0%b5%d0%bd%d0%bd%d0%be%d0%b9","status":"publish","type":"page","link":"https:\/\/docs.cpaas.mittoapi.net\/?page_id=845","title":{"rendered":"Var search"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/12\/variable_search1.png\"><img decoding=\"async\" width=\"114\" height=\"90\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/12\/variable_search1.png\" alt=\"\" class=\"wp-image-4020\"\/><\/a><\/figure>\n\n\n\n<p>The &#8220;Var search&#8221; block checks whether a variable exists. This block always has two outputs: Found and Not Found. Consequently, there are two possible paths for the scenario to proceed.<\/p>\n\n\n\n<p>The properties of this block include the fields &#8220;Variable&#8221; and &#8220;Nested object.&#8221; If a nested object is specified, the block will check for the existence of a specific object within the variable&#8217;s data structure (For more information about nested objects, see &#8220;<a href=\"https:\/\/docs.cpaas.mittoapi.net\/?page_id=837\">Variable<\/a>&#8220;).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/12\/variable_search2.png\"><img decoding=\"async\" width=\"271\" height=\"227\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/12\/variable_search2.png\" alt=\"\" class=\"wp-image-4022\"\/><\/a><\/figure>\n\n\n\n<p>For example, if you want to extract data from JSON, you need to pass this data into the &#8220;Nested object&#8221; field. For instance, if a user provides a phone number, and you need to retrieve it in international dialing format, you should specify &#8216;phone&#8217; in the &#8220;Nested object&#8221; field of the &#8220;Variable&#8221; block.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/12\/variable_search3.png\"><img decoding=\"async\" width=\"276\" height=\"235\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/12\/variable_search3.png\" alt=\"\" class=\"wp-image-4023\"\/><\/a><\/figure>\n\n\n\n<p>Scenario example:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/12\/variable_search4.png\"><img decoding=\"async\" width=\"386\" height=\"557\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/12\/variable_search4.png\" alt=\"\" class=\"wp-image-4024\" srcset=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/12\/variable_search4.png 386w, https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/12\/variable_search4-208x300.png 208w\" sizes=\"(max-width: 386px) 100vw, 386px\" \/><\/a><\/figure>\n\n\n\n<p>To search in an array that comes, for example, from an HTTP request (which is saved and stored in a variable, such as var1):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;\n{\n   \"name\":\"Ford\",\n   \"val\":\"John\",\n   \"price\":\"1000\",\n   \"cars\":&#91; \"Ford\", \"BMW\", \"Fiat\" ]\n},\n{\n   \"name\": \"BMW\",\n   \"val\":\"Jack\",\n   \"price\":\"2000\",\n   \"cars\":&#91; \"Ford\", \"BMW\", \"Fiat\" ]\n},\n{\n   \"name\": \"Fiat\",\n   \"val\":\"Nik\",\n   \"price\":\"3000\",\n   \"cars\":&#91; \"Ford\", \"BMW\", \"Fiat\" ]\n}\n]<\/code><\/pre>\n\n\n\n<p>To find the &#8220;Fiat&#8221; cars, you need to specify the following in the script fields:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var1&#91;0].cars&#91;2]<\/code><\/pre>\n\n\n\n<p>To do this, you need to specify in the fields:<\/p>\n\n\n\n<ol>\n<li>Variable: var1<\/li>\n\n\n\n<li>Nested object: [0].cars[2]<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/06\/variable2.png\"><img decoding=\"async\" width=\"807\" height=\"442\" src=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/06\/variable2.png\" alt=\"\" class=\"wp-image-3540\" srcset=\"https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/06\/variable2.png 807w, https:\/\/docs.cpaas.mittoapi.net\/wp-content\/uploads\/2024\/06\/variable2-300x164.png 300w\" sizes=\"(max-width: 807px) 100vw, 807px\" \/><\/a><\/figure>\n\n\n\n<p>This will create the element of the array var1[0].cars[2].<\/p>\n\n\n\n<p>This block can be used before the &#8220;Variable&#8221; and &#8220;Variable Analysis&#8221; blocks to have the system check the variable&#8217;s existence before assigning a value to it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The &#8220;Var search&#8221; block checks whether a variable exists. This block always has two outputs: Found and Not Found. Consequently, there are two possible paths for the scenario to proceed. The properties of this block include the fields &#8220;Variable&#8221; and &#8220;Nested object.&#8221; If a nested object is specified, the block will check for the existence <a href=\"https:\/\/docs.cpaas.mittoapi.net\/?page_id=845\" class=\"more-link\">&#8230;<span class=\"screen-reader-text\">  Var search<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":862,"menu_order":11,"comment_status":"closed","ping_status":"closed","template":"tpl\/scenario-personal.php","meta":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=\/wp\/v2\/pages\/845"}],"collection":[{"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=845"}],"version-history":[{"count":13,"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=\/wp\/v2\/pages\/845\/revisions"}],"predecessor-version":[{"id":4165,"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=\/wp\/v2\/pages\/845\/revisions\/4165"}],"up":[{"embeddable":true,"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=\/wp\/v2\/pages\/862"}],"wp:attachment":[{"href":"https:\/\/docs.cpaas.mittoapi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}