<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: DB Table to populate a List of values</title><link>https://answers.axonivy.com/questions/1823/db-table-to-populate-a-list-of-values</link><description>&lt;p&gt;Hi all,&lt;/p&gt;
&lt;p&gt;I'm newbie about AI designer. I'm trying to do something that it should be easy. I want to load a list of values in a Dialog (selectOneMenu) from a DB table. Suppose I have some employees. I want to create a new employee, so I need to assign it to amn existing department. So, I need an object List&amp;lt;department&amp;gt; in the Dialog interface to use it in the selectOneMenu control and save department code when I save this employee data to database.&lt;/p&gt;
&lt;p&gt;I'm not finding the way to connect the DB step when I make this query to the dialog step.&lt;/p&gt;
&lt;p&gt;Can you help me? Any documentation about this kind of tasks?&lt;/p&gt;
&lt;p&gt;BR&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/1823/db-table-to-populate-a-list-of-values" rel="self"></atom:link><language>en</language><lastBuildDate>Mon, 27 Jun 2016 10:30:08 -0400</lastBuildDate><item><title>Answer by Reto Weiss</title><link>https://answers.axonivy.com/questions/1823/db-table-to-populate-a-list-of-values/1847</link><description>&lt;p&gt;Hi 
You can use the database element to load the values from the database and store them in a Recordset. Then use the values in the Recordset on the Dialog.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;HTML Dialog with the following Data Class
&lt;img alt="alt text" src="http://answers.axonivy.com/upfiles/DataClass.PNG"&gt;&lt;/p&gt;
&lt;p&gt;The Recordset users is loaded by a Database Process Element from a Table in a database. The we use this Recordset in the View like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  &amp;lt;p:selectOneMenu value="#{data.userId}" &amp;gt;
    &amp;lt;f:selectItems value="#{data.users}" var="user" itemLabel="#{user.getField('FullName')}" itemValue="#{user.getField('UserId')}"/&amp;gt;
  &amp;lt;/p:selectOneMenu&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The value that is displayed is the column &lt;code&gt;FullName&lt;/code&gt; of the table (itemLabel). The value that is selected is the column &lt;code&gt;UserId&lt;/code&gt; of the table (itemValue). The itemValue of the selected record is stored in the variable &lt;code&gt;data.userId&lt;/code&gt;. &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reto Weiss</dc:creator><pubDate>Mon, 27 Jun 2016 10:30:08 -0400</pubDate><guid>https://answers.axonivy.com/questions/1823/db-table-to-populate-a-list-of-values/1847</guid></item></channel></rss>