- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2017 06:22 PM
Warning... javascript newbie here...
I have a List Collector that is finally working and need to push the user selected values to a string field in my table.
It appears I should be able to do this with an OnSubmit client script. It is my understanding the List Collector holds the Sys_Id references from the table.
Anyone able to provide an example for this? Currently, a comma separated list of Sys_ids is showing up in my table string field. I was trying this for starters.
function onSubmit() {
var divisions = producer.variable_pool.u_mg2divisions.toSting().split(',');
alert(divisions);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2017 12:47 PM
Finally, got this working !.. sheesh way tougher nut to crack than it should have been.
Set up a List Collector in Record Producer.
List Collector uses lookup table of names and IDs.
List Collector loads comma separated list of Sys_IDs to target table.
To convert Sys_ID's back to original names, add this to the Script section of the record producer.
current.u_mg2divisions = convertListCollector();
function convertListCollector() {
// Get List Collector values (a comma separated list of Sys_IDs)
var divArray = producer.Your_RecProd_FieldName.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('YourSourceTableName'); // 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(); // Should not need a while/loop since Sys_ID should have only one record.
var divValue = recObj.u_divname; // 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;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2017 12:47 PM
Finally, got this working !.. sheesh way tougher nut to crack than it should have been.
Set up a List Collector in Record Producer.
List Collector uses lookup table of names and IDs.
List Collector loads comma separated list of Sys_IDs to target table.
To convert Sys_ID's back to original names, add this to the Script section of the record producer.
current.u_mg2divisions = convertListCollector();
function convertListCollector() {
// Get List Collector values (a comma separated list of Sys_IDs)
var divArray = producer.Your_RecProd_FieldName.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('YourSourceTableName'); // 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(); // Should not need a while/loop since Sys_ID should have only one record.
var divValue = recObj.u_divname; // 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;
}