<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Local Variables in Reusable Interface</title><link>https://community.appian.com/discussions/f/new-to-appian/26087/local-variables-in-reusable-interface</link><description>Hi! 
 
 I created an interface with cardChoiceField, which allows me to choose one of multiple subinterfaces (via rule!), which I created before. These subinterfaces have a dropdown which value is assigned to a local (to subinterface) variable. 
 The</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Local Variables in Reusable Interface</title><link>https://community.appian.com/thread/102297?ContentTypeID=1</link><pubDate>Mon, 03 Oct 2022 17:26:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:14031d5f-e601-4b1f-b34d-7d30ab0ce4f8</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;IMHO you&amp;#39;re &lt;span style="font-size:150%;"&gt;&lt;em&gt;&lt;strong&gt;way&lt;/strong&gt; &lt;/em&gt;&lt;/span&gt;over-complicating this.&amp;nbsp; Your parent need only save a marker / pointer of whichever child you currently want to show, instead of trying to save &lt;em&gt;the child itself&lt;/em&gt; into some sort of local variable.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  /*local!link: null,*/
  local!selection: null(),

  {
    a!cardChoiceField(
      label: &amp;quot;Select A Version&amp;quot;,
      data: {
        a!map(
          /*id: rule!IM_Child1,*/
          id: 1,
          icon: &amp;quot;globe-alt&amp;quot;,
          primaryText: &amp;quot;Text&amp;quot;
        ),
        a!map(
          /*id: rule!IM_Child2,*/
          id: 2,
          icon: &amp;quot;globe-europe&amp;quot;,
          primaryText: &amp;quot;Num&amp;quot;
        )
      },
      cardTemplate: a!cardTemplateBarTextStacked(
        id: fv!data.id,
        primaryText: fv!data.primaryText,
        icon: fv!data.icon,
        iconColor: &amp;quot;POSITIVE&amp;quot;
      ),
      saveInto: 
      /*{*/
        /*local!link*/
        local!selection,
      /*},*/
      value: local!selection,
      maxSelections: 1,
      validations: {}
    ),
    a!sectionLayout(
      label: &amp;quot;Selected...&amp;quot;,
      contents: {
        a!match(
          value: index(local!selection, 1, null()),
          equals: 1,
          then: a!boxLayout(label: &amp;quot;rule!IM_child1 would go here&amp;quot;),
          equals: 2,
          then: a!boxLayout(label: &amp;quot;rule!IM_child2 would go here&amp;quot;),
          
          default: {}
        )
      }
    )
  }
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/62/pastedimage1664818019000v1.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Local Variables in Reusable Interface</title><link>https://community.appian.com/thread/102267?ContentTypeID=1</link><pubDate>Mon, 03 Oct 2022 08:04:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e126474c-dc0b-44be-b622-40cfb0deb6ec</guid><dc:creator>Vladislav Morozov</dc:creator><description>&lt;p&gt;If I understood you correctly, the idea was to restructure the code in this manner:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!link: null,
  {
    a!cardChoiceField(
      label: &amp;quot;Select A Version&amp;quot;,
      data: {
        a!map(id: rule!IM_Child1, icon: &amp;quot;globe-alt&amp;quot;, primaryText: &amp;quot;Text&amp;quot;),
        a!map(id: rule!IM_Child2, icon: &amp;quot;globe-europe&amp;quot;, primaryText: &amp;quot;Num&amp;quot;)
      },
      cardTemplate: a!cardTemplateBarTextStacked(
        id: fv!data.id,
        primaryText: fv!data.primaryText,
        icon: fv!data.icon,
        iconColor: &amp;quot;POSITIVE&amp;quot;
      ),
      saveInto: {local!link},
      maxSelections: 1,
      validations: {}
    ),
    a!sectionLayout(
      label: &amp;quot;&amp;quot;,
      contents: local!link()
    )
  })&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;but it gives me the following error:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong class="StrongText---richtext_strong StrongText---inMessageLayout StrongText---error"&gt;Could not display interface. Please check definition and inputs.&lt;/strong&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Interface Definition: Expression evaluation error at function local!link [line 22]: The function &amp;#39;link&amp;#39; is unavailable.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Local Variables in Reusable Interface</title><link>https://community.appian.com/thread/102253?ContentTypeID=1</link><pubDate>Sun, 02 Oct 2022 14:57:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e7dbeb83-801c-401f-a0ca-dc961c5910ce</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;I thin the issue here is, that you put the output of the called child interfaces into the id field of your maps. These will when behave in a static way. I suggest to just pass references to these interfaces to the id field but omitting the brackets. The evaluate the child interfaces like this:&lt;/p&gt;
&lt;p&gt;contents: local!link()&lt;/p&gt;
&lt;p&gt;Check out my recent blog article for more details:&amp;nbsp;&lt;a href="https://appian.rocks/2022/09/19/building-customisable-components/"&gt;https://appian.rocks/2022/09/19/building-customisable-components/&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Local Variables in Reusable Interface</title><link>https://community.appian.com/thread/102226?ContentTypeID=1</link><pubDate>Fri, 30 Sep 2022 20:08:43 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b7363293-65a0-4d07-9872-d12ba68ead4e</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Your child interfaces need to actually save their values up into the parent interface.&amp;nbsp; I&amp;#39;m not altogether clear what you&amp;#39;re doing in this example exactly, but it&amp;#39;s pretty clear to me that no value ever gets saved from the child to the parent. &amp;nbsp;In both of your child interface examples here the local variables are scoped such that they&amp;#39;d only be accessible locally.&lt;/p&gt;
&lt;p&gt;There&amp;#39;s not some sort of &amp;quot;magic&amp;quot; that makes data in a child interface automatically promote up to a parent interface, you actually have to build that into your structure.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Local Variables in Reusable Interface</title><link>https://community.appian.com/thread/102178?ContentTypeID=1</link><pubDate>Fri, 30 Sep 2022 09:06:36 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:cd328910-4b40-4f90-9079-ca1fe8d0978a</guid><dc:creator>Vladislav Morozov</dc:creator><description>&lt;p&gt;I think I&amp;#39;m not allowed to post the original code, so I created an example with the same type of problem&lt;/p&gt;
&lt;p&gt;Here is the parent:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!link: null(),
  {
    a!cardChoiceField(
      label: &amp;quot;Select A Version&amp;quot;,
      data: {
        a!map(id: rule!IM_Child1(), icon: &amp;quot;globe-alt&amp;quot;, primaryText: &amp;quot;Text&amp;quot;),
        a!map(id: rule!IM_Child2(), icon: &amp;quot;globe-europe&amp;quot;, primaryText: &amp;quot;Num&amp;quot;)
      },
      cardTemplate: a!cardTemplateBarTextStacked(
        id: fv!data.id,
        primaryText: fv!data.primaryText,
        icon: fv!data.icon,
        iconColor: &amp;quot;POSITIVE&amp;quot;
      ),
      saveInto: {local!link},
      maxSelections: 1,
      validations: {}
    ),
    a!sectionLayout(
      label: &amp;quot;&amp;quot;,
      contents: local!link
    )
  })&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Here is child 1:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!var:{&amp;quot;text1&amp;quot;, &amp;quot;text2&amp;quot;, &amp;quot;text3&amp;quot;},
  local!res:null,
  {
  a!dropdownField(
    label: &amp;quot;Dropdown&amp;quot;,
    labelPosition: &amp;quot;ABOVE&amp;quot;,
    placeholder: &amp;quot;--- Select a Value ---&amp;quot;,
    choiceLabels: local!var,
    choiceValues: local!var,
    value: local!res,
    saveInto: {local!res},
    searchDisplay: &amp;quot;AUTO&amp;quot;,
    validations: {}
  ),
  a!textField(
    label: &amp;quot;Text&amp;quot;,
    value: local!res,
    labelPosition: &amp;quot;ABOVE&amp;quot;,
    saveInto: {},
    refreshAfter: &amp;quot;UNFOCUS&amp;quot;,
    validations: {},
    showWhen: a!isNotNullOrEmpty(local!res)
  )
})&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here is child 2:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!var:{&amp;quot;num1&amp;quot;, &amp;quot;num2&amp;quot;, &amp;quot;num3&amp;quot;},
  local!res:null,
  {
    a!dropdownField(
      label: &amp;quot;Dropdown&amp;quot;,
      labelPosition: &amp;quot;ABOVE&amp;quot;,
      placeholder: &amp;quot;--- Select a Value ---&amp;quot;,
      choiceLabels: local!var,
      choiceValues: local!var,
      value: local!res,
      saveInto: {local!res},
      searchDisplay: &amp;quot;AUTO&amp;quot;,
      validations: {}
    ),
    a!textField(
      label: &amp;quot;Text&amp;quot;,
      value: local!res,
      labelPosition: &amp;quot;ABOVE&amp;quot;,
      saveInto: {},
      refreshAfter: &amp;quot;UNFOCUS&amp;quot;,
      validations: {},
      showWhen: a!isNotNullOrEmpty(local!res)
    )
  })&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;To recreate the problem you have to:&lt;/p&gt;
&lt;p&gt;1. Select &amp;quot;Text&amp;quot; choice.&lt;/p&gt;
&lt;p&gt;2. Choose any value in dropdown.&lt;/p&gt;
&lt;p&gt;3. See nothing has changed.&lt;/p&gt;
&lt;p&gt;4. Switch to &amp;quot;Num&amp;quot; choice.&lt;/p&gt;
&lt;p&gt;5. Switch back to &amp;quot;Text&amp;quot; choice.&lt;/p&gt;
&lt;p&gt;6. At this point I obtain the &amp;quot;Text&amp;quot; interface with refreshed variable.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Local Variables in Reusable Interface</title><link>https://community.appian.com/thread/102176?ContentTypeID=1</link><pubDate>Fri, 30 Sep 2022 08:29:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4100349b-4f3b-4acc-ba34-658387932e96</guid><dc:creator>Harshit Bumb (Appyzie)</dc:creator><description>&lt;p&gt;Can you paste the code here for one of the child interfaces where you are facing this problem along with the parent?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Local Variables in Reusable Interface</title><link>https://community.appian.com/thread/102175?ContentTypeID=1</link><pubDate>Fri, 30 Sep 2022 08:26:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6d051f24-ab63-4654-af8a-f82735840bbe</guid><dc:creator>Harshit Bumb (Appyzie)</dc:creator><description>&lt;p&gt;That should not be happening in the first place. I am not sure what is the reason but to explain the interaction when you create local variables in that interface, the scope is limited to that interface only but when you call that interface in a new interface (parent) then you will be able to interact with the components and store their values in the child interface&amp;#39;s locals and will also able to see them but cannot access them in the parent. If it made sense.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>