Value List

I have an issue where I have set the custom value of a value list successfully to a sql statement using a method as follows:

var query = 'SELECT concat(u.first_name," ",u.last_name) as account_manager FROM ss_users u, ss_users_group_assignments uga WHERE uga.user_id=u.id AND u.enabled=1 AND u.talent_id < 1 AND uga.group_id= 7 GROUP BY u.id ORDER BY u.last_name, u.first_name'; 
var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, 250);

application.setValueListItems(‘account_managers’,dataset);

Here’s the issue though: I need the primary key to be stored in the field displaying either the “pk - first name last name” or just “first name last name” and when the user selects the value the pk is stored in the field.

Does anyone have any pointers on how to achieve this?

application.setValueListItems() should do it for you.

the 1st argument = the name of the list
the 2nd argument = the values you want displayed
the 3rd (optional) argument = the values you want stored

Hope this helps (btw simply pull the sample and you know what to do).

Do you have any code samples on how to do this?

This is what you get if you right click on application.setValueListItems() and choose “move sample”:

//Fill a custom type valuelist with values from array(s) or dataset
//set display values (return values will be same as display values)
application.setValueListItems(‘my_en_types’,new Array(‘Item 1’, ‘Item 2’, ‘Item 3’));
//set display values and return values (which are stored in dataprovider)
//application.setValueListItems(‘my_en_types’,new Array(‘Item 1’, ‘Item 2’, ‘Item 3’),new Array(10000,10010,10456));
//do query and fill valuelist (see databaseManager for full details of queries/dataset)
//var query = ‘select c1,c2 from test_table’;
//var dataset = databaseManager.getDataSetByQuery(controller.getServerName(), query, null, 25);

//application.setValueListItems(‘my_en_types’,dataset);

Thanks so much, let me try that out :-)