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-18-2016 09:18 AM
SN is sending the sys_id over instead of a plain letter value

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2016 12:33 PM
Any time you see a sys_id and want the display value, the general fix is to use the getDisplayValue() method on the object.
var fruit = current.getValue('u_fruit'); // get the sys_ids
var fruitArr = fruit.split(',');
var fruitVal = [];
var fruitName = [];
var f = new GlideRecord('u_fruit_table');
f.addQuery('sys_id','IN',fruitArr.join(','));
f.query();
while(f.next()){
fruitVal.push(f.u_value.getDisplayValue());
fruitName.push(f.u_name.getDisplayValue());
}
// fruitVal is now an array of values. If you want it back to a comma separated string...
var returnVal = fruitVal.join(',');
var returnName = fruitName.join(',');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2016 12:43 PM
Right, Thanks at ton for your reply ctomasi.. . Tried that and getting an error still
more elaboration on this one, my BR is functioning for the WSDL and trying to pull these value's as well. typical WSDL syntax = s.setStringParameter('u_fruit' , current.u_fruit); . The issue I have here is when calling current.field it pulls the sysID info and errors out. is there something else i should be calling in my WSLD call? Do I need the array here, var fruitVal = [];var fruitName = []; or just the brackets?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2016 07:33 PM
You can include a sample of the code you are using and the result it is producing? I'm afraid I've lost the essence of what you are trying to accomplish in all the details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2016 11:15 AM