How can I write an Array in a Business Rule based on a form selection?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2016 09:51 AM
Hi all -
We have a List field on a form and the user needs to be able to select one or more for the slushbucket. On the backend I need the value of the selection to send in a SOAP message. However, I have a requirement for the name to be displayed...
Example:
type: 'Apple' , 'Banana' - what the customer needs to see on the form
value of type: 'A, B' - what i need to send
what is the best way to go about doing this? do i need a hidden field that gets the value of the selected? should i set up an array in the business rule on that field? This got way too complicated. Att the end of the day the user needs to see the selection and i need the value of that selection.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2016 10:06 AM
Thanks abhi_r ,
on my table the list is referencing, the name is set as the display value. I need to pull the value of the name from the other table, which is another column.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2016 10:09 AM
Sorry, I am confused here. Can you give an example illustrating what you need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2016 10:23 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2016 10:24 AM
I should have you covered. If you want both the value and the name, add another array to my script and push the value of the name field in to it along with the value.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2016 10:39 AM
Just a minor chnage to chuck's code. Instead of looping it, you can use IN operator in query as shown below for better performance.
var fruit = current.getValue('u_fruit'); // get the sys_ids
var fruitArr = fruit.split(',');
var fruitVal = [];
var f = new GlideRecord('u_fruit_table');
f.addQuery('sys_id','IN',fruitArr.join());
f.query();
while(f.next()){
fruitVal.push(f.getValue('u_value'))'
}
// fruitVal is now an array of values. If you want it back to a comma separated string...
var returnString = fruitVal.join(',');