How can I write an Array in a Business Rule based on a form selection?

paul971
Mega Expert

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.

22 REPLIES 22

SN is sending the sys_id over instead of a plain letter value


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(',');


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?


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.


Thanks again ctomasi & abhi_r for your collaboration.



I'm going to plug this into the BR and see what comes out.



Just to be clear, the Display Value will remain from the user perspective but this will send the value I need on my SOAP message?