{"id":5163,"date":"2017-09-22T19:37:41","date_gmt":"2017-09-22T19:37:41","guid":{"rendered":"https:\/\/alt2.minisoft.com\/support\/?p=5163"},"modified":"2021-02-09T15:30:11","modified_gmt":"2021-02-09T23:30:11","slug":"set-value-from-a-keyed-declared-constant","status":"publish","type":"post","link":"https:\/\/c002.minisoft.com\/support\/set-value-from-a-keyed-declared-constant\/","title":{"rendered":"Set Value from a Keyed Declared Constant"},"content":{"rendered":"<p>For examples on how to implement Declared Constants, consult the following: <a href=\"\/support\/index.php\/declared-constants-for-production-vs-dev-sandbox-accounts\/\">Declared Constants for Production vs. Dev\/Sandbox Accounts<\/a><\/p>\n<p>A Keyed Declared Constant from an eFORMzCfg_User.xml file provides the value for this Variable Function.<\/p>\n<p><a href=\"https:\/\/alt2.minisoft.com\/support\/wp-content\/uploads\/2017\/09\/KeyedDeclare.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-5164\" src=\"https:\/\/alt2.minisoft.com\/support\/wp-content\/uploads\/2017\/09\/KeyedDeclare.jpg\" alt=\"\" width=\"330\" height=\"233\" srcset=\"https:\/\/c002.minisoft.com\/support\/wp-content\/uploads\/2017\/09\/KeyedDeclare.jpg 330w, https:\/\/c002.minisoft.com\/support\/wp-content\/uploads\/2017\/09\/KeyedDeclare-300x212.jpg 300w, https:\/\/c002.minisoft.com\/support\/wp-content\/uploads\/2017\/09\/KeyedDeclare-150x106.jpg 150w, https:\/\/c002.minisoft.com\/support\/wp-content\/uploads\/2017\/09\/KeyedDeclare-250x177.jpg 250w, https:\/\/c002.minisoft.com\/support\/wp-content\/uploads\/2017\/09\/KeyedDeclare-255x180.jpg 255w\" sizes=\"(max-width: 330px) 100vw, 330px\" \/><\/a><\/p>\n<p>The form of a declaration is:<\/p>\n<pre>&lt;KeyedConstant Name=\u201cOrderNbrLabels\u201d&gt;\n &lt;Entry Key=\u201cEN\u201d&gt;\n &lt;![CDATA[Order Number]]&gt;\n &lt;\/Entry&gt;\n &lt;Entry Key=\u201cFR\u201d&gt;\n &lt;![CDATA[French Order Number]]&gt;\n &lt;\/Entry&gt;\n &lt;\/KeyedConstant&gt;<\/pre>\n<p>If this Function is used in a number of Projects to refer to the same Keyed Declared Constant, when the Keyed Declared Constant must change, only the eFORMzCfg_User.xml file needs to be modified, not each Project.<\/p>\n<p><strong>Note: Changes to the eFORMzCfg.xml will get overwritten as this file is updated or overwritten on upgrades and installs.<\/strong><\/p>\n<p>You should consider using a Keyed Declared Constant when you need to choose one of several static values, depending on the value of some variable. Here are some examples:<\/p>\n<p>\u2022 <a href=\"\/support\/index.php\/how-to-use-eformz-to-create-drop-ship-pack-slips\/\">In a drop-ship packing slip project<\/a>, you support several packing slip types, and you want to choose the one to use based on the value of the customer ID.<br \/>\n\u2022 You have test and production credentials <a href=\"\/support\/index.php\/eformz-api-management-developer-resources\/\">to be passed to a web service call<\/a> and you need to choose the appropriate set of credentials depending on whether you\u2019re running in test or in production. Create a Keyed Declared Constant for each credential, such as URL to call, user name, password, token, etc.\u201d<\/p>\n<h2>Language Substitution<\/h2>\n<p>1. Add another Variable by position and enter \u2018OrderNbrLabel1\u2019 in the Name field.<br \/>\n2. Right click the Variable and select Add Function &gt; Set value from a keyed declared constant.<br \/>\n3. Select the \u2018OrderNbrLabels\u2019 Keyed Declared Constant which was declared in the eFORMzCfg_Translations.xml. The Key Value should should be the Language Variable. The Keyed Constant is as follows:<\/p>\n<pre>&lt;KeyedConstant Name=\u201cOrderNbrLabels\u201d&gt;\n &lt;Entry Key=\u201cEN\u201d&gt;\n &lt;![CDATA[Order Number]]&gt;\n &lt;\/Entry&gt;\n &lt;Entry Key=\u201cFR\u201d&gt;\n &lt;![CDATA[French Order Nbr]]&gt;\n &lt;\/Entry&gt;\n &lt;Entry Key=\u201cGE\u201d&gt;\n &lt;![CDATA[German Order Number]]&gt;\n &lt;\/Entry&gt;\n &lt;\/KeyedConstant&gt;<\/pre>\n<p>The two-letter language code from the incoming data file will be picked up by the Language Variable. This is the Key Value, or the \u2018Entry Key.\u2019 For example, if the language code is \u2018FR\u2019 then the value of the \u2018OrderNbrLabel1\u2019 Variable will be the French Order Number.<\/p>\n<h3>Load Variable From a Keyed Declared Constant Pre-condition Procedure<\/h3>\n<p>1. Add another Variable by position and enter \u2018OrderNbrLabel2\u2019 in the Name field.<br \/>\n2. Right click the Form and select Add Pre-condition Procedure &gt; Load Variable from a Keyed Declared Constant.<br \/>\n3. Enter a value for the Name field and select the System Variable \u2018N\/A\u2019 from the Use variable drop-down menu.<br \/>\n4. Select the \u2018OrderNbrLabels\u2019 Keyed Declared Constant which was declared in the eFORMzCfg_Translations.xml. The Key Value should should be the Language Variable. The Variable should be the \u2018OrderNbrLabel2\u2019 Variable. The Keyed Constant is as follows:<\/p>\n<pre>&lt;KeyedConstant Name=\u201cOrderNbrLabels\u201d&gt;\n &lt;Entry Key=\u201cEN\u201d&gt;\n &lt;![CDATA[Order Number]]&gt;\n &lt;\/Entry&gt;\n &lt;Entry Key=\u201cFR\u201d&gt;\n &lt;![CDATA[French Order Nbr]]&gt;\n &lt;\/Entry&gt;\n &lt;Entry Key=\u201cGE\u201d&gt;\n &lt;![CDATA[German Order Number]]&gt;\n &lt;\/Entry&gt;\n &lt;\/KeyedConstant&gt;<\/pre>\n<p>The two-letter language code from the incoming data file will be picked up by the Language Variable. This is the Key Value, or the \u2018Entry Key.\u2019 For example, if the language code is \u2018FR\u2019 then the value of the \u2018OrderNbrLabel2\u2019 Variable will be the French Order Number.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For examples on how to implement Declared Constants, consult the following: Declared Constants for Production vs. Dev\/Sandbox Accounts A Keyed Declared Constant from an eFORMzCfg_User.xml file provides the value for this Variable Function. The form of a declaration is: &lt;KeyedConstant Name=\u201cOrderNbrLabels\u201d&gt; &lt;Entry Key=\u201cEN\u201d&gt; &lt;![CDATA[Order Number]]&gt; &lt;\/Entry&gt; &lt;Entry Key=\u201cFR\u201d&gt; &lt;![CDATA[French Order Number]]&gt; &lt;\/Entry&gt; &lt;\/KeyedConstant&gt; If this [&hellip;]<\/p>\n","protected":false},"author":75,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[682],"_links":{"self":[{"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/5163"}],"collection":[{"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/users\/75"}],"replies":[{"embeddable":true,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/comments?post=5163"}],"version-history":[{"count":5,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/5163\/revisions"}],"predecessor-version":[{"id":8954,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/5163\/revisions\/8954"}],"wp:attachment":[{"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/media?parent=5163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/categories?post=5163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/tags?post=5163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}