{"id":1656,"date":"2022-02-18T13:30:58","date_gmt":"2022-02-18T13:30:58","guid":{"rendered":"https:\/\/info.documotor.com\/?page_id=1656"},"modified":"2023-03-07T09:32:06","modified_gmt":"2023-03-07T09:32:06","slug":"datasource","status":"publish","type":"page","link":"https:\/\/info.documotor.com\/?page_id=1656","title":{"rendered":"Data Sources"},"content":{"rendered":"\n<p>A data source represents static data that can be used within your transformation. There are no requirements to the format of the data, except it has to be wrapped in a square bracketed JSON array. <\/p>\n\n\n\n<p>To <strong>create a new data source<\/strong>, do it under Data Sources navigation section.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"645\" height=\"614\" src=\"https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/05\/image.png\" alt=\"\" class=\"wp-image-2383\" srcset=\"https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/05\/image.png 645w, https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/05\/image-300x286.png 300w\" sizes=\"(max-width: 645px) 100vw, 645px\" \/><\/figure>\n\n\n\n<h2>JMES function<\/h2>\n\n\n\n<p>In order to use data from a data source in your transformation or in a function, use this syntax:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">datasource('dataSourceName', 'column', 'lookFor') <\/code><\/pre>\n\n\n\n<p><strong>dataSourceName<\/strong>: Name of the data source to use.<\/p>\n\n\n\n<p><strong>column<\/strong>: Name of the column.<\/p>\n\n\n\n<p><strong>lookFor<\/strong>: Exact match on the value in specified column.<\/p>\n\n\n\n<p><strong>returns<\/strong>: An object in a data source based on the arguments.<\/p>\n\n\n\n<h2>Example<\/h2>\n\n\n\n<p>In this example we refer directly to data source, and define the metadata in the transformation. Normally, you&#8217;d likely derive the metadata from the sample data payload.<\/p>\n\n\n\n<pre title=\"My_datasource\" class=\"wp-block-code\"><code lang=\"json\" class=\"language-json\">[{\n    \"DocSize\" : \"USLetter\",\n    \"TableWidth\" : 13,\n    \"PrinterTrayOptions\" : {\n        \"Name\" : \"Black\/White 2\",\n        \"DoubleSided\" : false\n     }\n  }, {\n    \"DocSize\" : \"A4\",\n    \"TableWidth\" : 11.3,\n    \"PrinterTrayOptions\" : {\n        \"Name\" : \"Black\/White 2\",\n        \"DoubleSided\" : true\n    }\n}]<\/code><\/pre>\n\n\n\n<p>Data source is wrapped in square brackets. <\/p>\n\n\n\n<p>Each object of the array consists of a few different values that showcases that multiple data formats (integers, strings and bools) are supported.<\/p>\n\n\n\n<pre title=\"Transformation\" class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">{\n  \/\/metadata\n  DocSize: 'USLetter',\n\n  TableWidth: datasource('My_datasource', 'DocSize', $.DocSize).TableWidth,\n  PrinterTray: datasource('My_datasource', 'DocSize', $.DocSize).PrinterTrayOptions\n}<\/code><\/pre>\n\n\n\n<p>The metadata (which might have been taken from the payload, but in this case is defined as a string in the transformation), defines the DocSize as USLetter.<\/p>\n\n\n\n<p>The <strong>dataSourceName<\/strong> is &#8220;My_datasource&#8221;, the <strong>column<\/strong> we&#8217;re matching is &#8220;DocSize&#8221;, and the <strong>lookFor<\/strong>-value is is the &#8220;DocSize&#8221;-value defined in the metadata. Using affixes and normal JMESPATH syntax, we <strong>return<\/strong> TableWidth and PrinterTrayOptions from the data source based on which DocSize is defined.<\/p>\n\n\n\n<pre title=\"Output\" class=\"wp-block-code\"><code lang=\"json\" class=\"language-json\">{\n  \"DocSize\": \"USLetter\",\n  \"TableWidth\": 13,\n  \"PrinterTray\": {\n    \"Name\": \"Black\/White 2\",\n    \"DoubleSided\": false\n  }\n}<\/code><\/pre>\n\n\n\n<div class=\"wp-container-1 wp-block-buttons\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>A data source represents static data that can be used within your transformation. There are no requirements to the format of the data, except it has to be wrapped in a square bracketed JSON array. To create a new data source, do it under Data Sources navigation section. JMES function In order to use data [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"parent":3160,"menu_order":5,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/1656"}],"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\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/info.documotor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1656"}],"version-history":[{"count":26,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/1656\/revisions"}],"predecessor-version":[{"id":5032,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/1656\/revisions\/5032"}],"up":[{"embeddable":true,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/3160"}],"wp:attachment":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}