
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2018 02:56 PM
Hi There,
I have a function in a business rule to convert the values from a list collector's sys_id to return them as string values to store in another table, but it is still return the sys_id values.
The business rule runs on the sc_req_item table - referencing the variable of the list collector: "lcMailboxes"
Using a GlideRecord to the other table "u_new_starter_templates" where the value is stored in column "u_shared_mailboxes"
My script is and I need to find out what I've missed to convert the values from sys_id to a string:
current.variables.lcMailboxes = convertListCollector();
function convertListCollector() {
var divArray = current.variables.lcMailboxes.toString().split(','); //split the list into an array
var outString = ''; //initialize clear the output string
for(i = 0; i < divArray.length; i++){ //Loop through List Collector Sys_ID array
var recObj = new GlideRecord('u_new_starter_templates'); //create table object
recObj.addQuery('sys_id',divArray[i]); //Create query to return record associated to Sys_ID
recObj.query(); //run the query
recObj.next();
var divValue = recObj.u_distribution_lists; //create variable with value from source field
if ( i == 0 ) {
outString = divValue; //don't start the string with a comma
} else {
outString = outString + ', ' + divValue; //append to output string variable
}
}
return outString;
}
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2018 03:00 PM
So you're receiving the sys_id because that's the value of a reference field. To get the actual "string" value you're referring to, that's the Display Value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2018 11:21 PM
use getDisplayValue() instead of toString()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2018 12:14 PM
Thanks all, I've got it working using getDisplayValue()