<?xml version="1.0" encoding="UTF-8" standalone="yes"?><oembed><version><![CDATA[1.0]]></version><provider_name><![CDATA[CloudForms Now]]></provider_name><provider_url><![CDATA[http://cloudformsblog.redhat.com]]></provider_url><author_name><![CDATA[johnhardy36]]></author_name><author_url><![CDATA[https://cloudformsblog.redhat.com/author/johnhardy36/]]></author_url><title><![CDATA[Dialogs &#8211; Dynamic&nbsp;DropDowns]]></title><type><![CDATA[link]]></type><html><![CDATA[<p>Its here and looks great. You can now populate a drop down list from an external source!</p>
<p>Simply create an Instance and Method, its advised you create a new Namespace to store dialog controls into rather than mixing them up into the general automation model.</p>
<p>The method requires the following code behind it;<!--more--></p>
<pre class="brush: ruby; title: ; notranslate" title="">
dialog_field = $evm.object&lt;/code&gt;

# sort_by: value / description / none
dialog_field[&quot;sort_by&quot;] = &quot;value&quot;

# sort_order: ascending / descending
#dialog_field[&quot;sort_order&quot;] = &quot;ascending&quot;

# data_type: string / integer
dialog_field[&quot;data_type&quot;] = &quot;integer&quot;

# required: true / false
#dialog_field[&quot;required&quot;] = &quot;true&quot;

#Return as a hash

dialog_field[&quot;values&quot;] = {1 =&amp;gt; &quot;one&quot;, 2 =&amp;gt; &quot;two&quot;, 10 =&amp;gt; &quot;ten&quot;, 50 =&amp;gt; &quot;fifty&quot;}

#Return as an array

dialog_field[&quot;values&quot;] = [[1, &quot;one&quot;], [2, &quot;two&quot;], [10, &quot;ten&quot;], [50, &quot;fifty&quot;]]

dialog_field[&quot;default_value&quot;] = 2

exit MIQ_OK
</pre>
<p>So the code is very simple, there are a number of settings you can control such as;</p>
<ul>
<li><span style="font-family:Consolas, Monaco, monospace;font-size:12px;line-height:18px;">data_type</span></li>
<li><span style="font-family:Consolas, Monaco, monospace;font-size:12px;line-height:18px;">sort_order</span></li>
<li><span style="font-family:Consolas, Monaco, monospace;font-size:12px;line-height:18px;">sort_by</span></li>
<li><span style="font-family:Consolas, Monaco, monospace;font-size:12px;line-height:18px;">required</span></li>
</ul>
<p>The the values are simply inserted into the drop down as EITHER a hash or array. The above example shows both, you would use either.</p>
<p>The next step is to create a dialog and add the element &#8220;Dynamic Dropdown List&#8221; to your form and set the NameSpace/Class/Instance to your Instance/Method you created in the previous step.</p>
<p>And what does it look like when finished?</p>
<p><a href="http://cloudformsnow.files.wordpress.com/2013/10/screen-shot-2013-10-24-at-11-56-29.png"><img data-attachment-id="200" data-permalink="https://cloudformsblog.redhat.com/screen-shot-2013-05-22-at-21-30-34/" data-orig-file="https://cloudformsredhat.files.wordpress.com/2013/05/screen-shot-2013-05-22-at-21-30-34.png" data-orig-size="1007,174" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Screen Shot 2013-05-22 at 21.30.34" data-image-description="" data-medium-file="https://cloudformsredhat.files.wordpress.com/2013/05/screen-shot-2013-05-22-at-21-30-34.png?w=300" data-large-file="https://cloudformsredhat.files.wordpress.com/2013/05/screen-shot-2013-05-22-at-21-30-34.png?w=1007" class="alignnone wp-image-200 size-large" src="https://cloudformsredhat.files.wordpress.com/2013/05/screen-shot-2013-05-22-at-21-30-34.png?w=1024&#038;h=178" alt="Screen Shot 2013-10-24 at 11.56.29" srcset="https://cloudformsredhat.files.wordpress.com/2013/05/screen-shot-2013-05-22-at-21-30-34.png 1007w, https://cloudformsredhat.files.wordpress.com/2013/05/screen-shot-2013-05-22-at-21-30-34.png?w=150&amp;h=26 150w, https://cloudformsredhat.files.wordpress.com/2013/05/screen-shot-2013-05-22-at-21-30-34.png?w=300&amp;h=52 300w, https://cloudformsredhat.files.wordpress.com/2013/05/screen-shot-2013-05-22-at-21-30-34.png?w=768&amp;h=133 768w" sizes="(max-width: 1007px) 100vw, 1007px"   /></a></p>
<p>The use cases for this are quite large, here are some;</p>
<ul>
<li>Populate the list of Load Balancer Pools available from F5 Big IP, allow the consumer to choose which pool to place their service into.</li>
<li>Populate the list with the available AMI&#8217;s in Amazon you wish to share off based on a tag.</li>
<li>Populate the list with the OpenStack environments available, allowing the user to place their Instance based on that or even linked to department etc..</li>
<li>Populate the list with catalogs from a software distribution system to allow the user to have collections of software installed into the service. This could be SCCM, Puppet, Chef etc..</li>
</ul>
]]></html><thumbnail_url><![CDATA[https://cloudformsredhat.files.wordpress.com/2013/05/screen-shot-2013-05-22-at-21-30-34.png?w=640&fit=440%2C330]]></thumbnail_url><thumbnail_width><![CDATA[438]]></thumbnail_width><thumbnail_height><![CDATA[76]]></thumbnail_height></oembed>