<?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>Dropdown loaded each with a different entity</title><link>https://community.appian.com/discussions/f/data/17162/dropdown-loaded-each-with-a-different-entity</link><description>Hi, 
 I try to have two dropdowns loaded each with a different entity. In turn, the two are related. That is, when I make the selection of one of them, I should only take the values ​​in the second that belong to the first one. Typical Province Community</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Dropdown loaded each with a different entity</title><link>https://community.appian.com/thread/67736?ContentTypeID=1</link><pubDate>Thu, 27 Jun 2019 08:23:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d170689c-5b67-484c-a2a5-5557637adda6</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;Yes, exactly. Or was that a question?&lt;/p&gt;
&lt;p&gt;You have two implementation options:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;retrieve the data for the first drop-down, and only retrieve the data for the second drop-down when a value in the first is selected&lt;/li&gt;
&lt;li&gt;retrieve ALL the data for BOTH drop-downs and perform the relevant look-up locally, exactly as in my example&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Which you choose depends on how much data there is, and how often you think someone will pick an option from the first drop-down.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dropdown loaded each with a different entity</title><link>https://community.appian.com/thread/67735?ContentTypeID=1</link><pubDate>Thu, 27 Jun 2019 08:15:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:88aacab0-7145-475a-a691-bd2be5d5d275</guid><dc:creator>alexc0002</dc:creator><description>&lt;p&gt;On your example, Fruit and Vegetable are in one table and the values ​​of the second dropdown in a different one. In turn the two related. In such a way that when the value is selected in the first dropdown, the query must be made to take the values ​​of the second table.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thx&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dropdown loaded each with a different entity</title><link>https://community.appian.com/thread/67734?ContentTypeID=1</link><pubDate>Thu, 27 Jun 2019 08:11:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:831fecb1-657e-4e0f-9bde-6ad995191875</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;So, everything will be effectively the same other than the assignment of the data to the local! variables.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dropdown loaded each with a different entity</title><link>https://community.appian.com/thread/67733?ContentTypeID=1</link><pubDate>Thu, 27 Jun 2019 08:09:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e31c6c46-7397-4340-ad01-cfb50dc2bcc9</guid><dc:creator>alexc0002</dc:creator><description>&lt;p&gt;&lt;span&gt;Thanks &lt;a class="internal-link view-user-profile" href="/members/stewart.burchell"&gt;Stewart&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Yes I need to manage the data in a database and retrieve it from there.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I must load the data from the database, not with local variables&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;Thx&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dropdown loaded each with a different entity</title><link>https://community.appian.com/thread/67696?ContentTypeID=1</link><pubDate>Wed, 26 Jun 2019 14:32:44 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0fa6512e-e299-43bc-b6c2-87528bcf6909</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;So, let&amp;#39;s approach this methodically. I&amp;#39;m going to use as an example two classifications - Fruit and Vegetables - as the values for the first drop-down, and then a few examples of each type for the values in the second drop-down.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;You need to find a way of relating the data. Typically we can put these into two database tables, with one table holding &amp;#39;Fruit&amp;#39; and &amp;#39;Vegetables&amp;#39; and the second holding all the examples but with a Foreign Key that points to either &amp;#39;Fruit&amp;#39; or &amp;#39;Vegetable&amp;#39; in the first table&lt;/li&gt;
&lt;li&gt;In your interface you will load the values of the first drop-down, whilst the second drop-down will initially be empty (and even not visible if that is the UX you want to achieve)&lt;/li&gt;
&lt;li&gt;When you pick a value in the first drop-down you can use the associated key to retrieve all of the related items from the second table using&amp;nbsp;it&amp;#39;s value to match the values in the Foreign Key column&lt;/li&gt;
&lt;li&gt;Lastly you&amp;#39;ll need to also cater for the scenario where a null value is selected in the first drop-down (which should clear out the content of the second drop-down)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The main thing is to design the data model to allow the contents of the second-drop down to be a sub-selection of the full set of data, based upon the value selected from the first drop-down.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s an example where I&amp;#39;ve hard-coded the list of data into the load() variables. but you may well want to manage the data in a database and retrieve it from there.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;load(
  local!classifications: {
    {ClassificationKey: 1, classification: &amp;quot;Fruit&amp;quot;},
    {ClassificationKey: 2, classification: &amp;quot;Vegetable&amp;quot;}
  },
  local!examples: {
    {ExampleKey: 1, ClassificationKey: 1, example: &amp;quot;Apple&amp;quot;},
    {ExampleKey: 2, ClassificationKey: 1, example: &amp;quot;Banana&amp;quot;},
    {ExampleKey: 3, ClassificationKey: 1, example: &amp;quot;Cherry&amp;quot;},
    {ExampleKey: 4, ClassificationKey: 2, example: &amp;quot;Artichoke&amp;quot;},
    {ExampleKey: 5, ClassificationKey: 2, example: &amp;quot;Broccoli&amp;quot;},
    {ExampleKey: 6, ClassificationKey: 2, example: &amp;quot;Celery&amp;quot;}
  },
  local!selectedClassification: tointeger(null),
  local!selectedExample: tointeger(null),
  local!exampleSubset: {},
  {
    a!columnsLayout(
      columns: {
        a!columnLayout(
          contents: {
            a!dropdownField(
              label: &amp;quot;Classification&amp;quot;,
              value: local!selectedClassification,
              saveInto: {
                local!selectedClassification,
                a!save(
                  local!selectedExample,
                  null
                ),
                a!save(
                  local!exampleSubset,
                  local!examples[fn!wherecontains(save!value,local!examples.ClassificationKey)]
                )
              },
              placeholderLabel: &amp;quot;---Select a Classification---&amp;quot;,
              choiceLabels: local!classifications.classification,
              choiceValues: local!classifications.ClassificationKey
            )
          }
        ),
        a!columnLayout(
          contents: {
            a!dropdownField(
              instructions: local!exampleSubset,
              label: &amp;quot;Example&amp;quot;,
              value: local!selectedExample,
              saveInto: {
                local!selectedExample
              },
              placeholderLabel: &amp;quot;---Select an Example---&amp;quot;,
              choiceLabels: fn!index(local!exampleSubset,&amp;quot;example&amp;quot;,{}),
              choiceValues: fn!index(local!exampleSubset,&amp;quot;ExampleKey&amp;quot;,{}),
            )
          }
        )
      }
    )
  }
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dropdown loaded each with a different entity</title><link>https://community.appian.com/thread/67694?ContentTypeID=1</link><pubDate>Wed, 26 Jun 2019 14:14:03 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f83c61b8-cc3b-4920-b372-6c2a8893e82a</guid><dc:creator>Malleswari Talakola</dc:creator><description>&lt;p&gt;1. You can save the value of second dropdown&amp;nbsp;variable to be shown after selection into the first dropdown Saveinto(a!save).&lt;/p&gt;
&lt;p&gt;2. or, you can write a showwhen condition on each dropdown, and define as if selection label is &amp;gt;1 show first label related dropdown, &amp;gt; 2 second label&amp;nbsp;dropdown etc.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>