{"id":3732,"date":"2022-11-15T12:13:45","date_gmt":"2022-11-15T12:13:45","guid":{"rendered":"https:\/\/info.documotor.com\/?page_id=3732"},"modified":"2023-01-25T10:16:18","modified_gmt":"2023-01-25T10:16:18","slug":"datasource","status":"publish","type":"page","link":"https:\/\/info.documotor.com\/?page_id=3732","title":{"rendered":"Datasource"},"content":{"rendered":"\n<p>The datasource function is the part of the DocuMotor <a href=\"https:\/\/info.documotor.com\/?page_id=1656\">datasource functionality<\/a> that goes into the JMES transformation. <\/p>\n\n\n\n<h3>Syntax<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">json_object datasource(string $dataSource, string $column, string $value)<\/code><\/pre>\n\n\n\n<p>This function fetches data from the specified $dataSource, filtering by $value lookup in $column. Function returns the entire JSON object where match is found.<\/p>\n\n\n\n<h3>Parameters<\/h3>\n\n\n\n<p><strong>$datasource:<\/strong> The name of the data source to pull data from. Must be string value.<br><strong>$column: <\/strong>The key to evaluate. Must be string value.<br><strong>$value: <\/strong>The value to match. Must be string value.<\/p>\n\n\n\n<h3>Example<\/h3>\n\n\n\n<p>Rather than being data from an external system, below is from a DocuMotor data source.<\/p>\n\n\n\n<pre title=\"DataSourceName\" class=\"wp-block-code\"><code lang=\"json\" class=\"language-json line-numbers\">[\n    {\n        \"input\" : \"USD\",\n        \"iana\" : \"en-US\"\n    }, \n    {\n        \"input\" : \"DKK\",\n        \"iana\" : \"da-DK\"\n    }\n]<\/code><\/pre>\n\n\n\n<p>The above data can be read as a table where keys are column headers and values are row data.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-left\" data-align=\"left\"><strong>input<\/strong><\/td><td><strong>iana<\/strong><\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">USD<\/td><td>en-US<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\">DKK<\/td><td>da-DK<\/td><\/tr><\/tbody><\/table><figcaption>Visualisation of JSON data source as a table<\/figcaption><\/figure>\n\n\n\n<pre title=\"Transformation\" class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">{\n    culture: datasource('DataSourceName', 'input', 'USD')\n}<\/code><\/pre>\n\n\n\n<p>In above transformation, data source called &#8220;DataSourceName&#8221; is invoked. The column (or key) is defined to be &#8220;input&#8221; and the value to match is &#8220;USD&#8221;. This returns below JSON object from the data source.<\/p>\n\n\n\n<pre title=\"Output\" class=\"wp-block-code\"><code lang=\"json\" class=\"language-json line-numbers\">{\n    \"culture\": {\n        \"input\": \"USD\",\n        \"iana\": \"en-US\"\n    }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The datasource function is the part of the DocuMotor datasource functionality that goes into the JMES transformation. Syntax This function fetches data from the specified $dataSource, filtering by $value lookup in $column. Function returns the entire JSON object where match is found. Parameters $datasource: The name of the data source to pull data from. Must [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"parent":271,"menu_order":30,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/3732"}],"collection":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/info.documotor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3732"}],"version-history":[{"count":9,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/3732\/revisions"}],"predecessor-version":[{"id":3797,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/3732\/revisions\/3797"}],"up":[{"embeddable":true,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/271"}],"wp:attachment":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}