
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2021 05:31 PM
Hi,
I have a list collector field on a custom table. I would like to add on records from a reference table to this list whenever a filter criteria is met. My current business rule will trigger and replace all content of this list field instead of adding the records to the list. Would appreciate any help on a business rule script to meet this objective. Thank you!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2021 05:54 PM
Hi, without specific details of what\where\how you are doing this, it is hard to provide exact details but your basic script might be something like this
var myReferenceArray = [];
//Query your reference data
var mySource = new GlideRecord('mySourceTable');
mySource.addQuery('field', referenceValue);
mySource.query();
//iterate through the results and push records into an array
while(mySource.next() {
myReferenceArray.push(mySource.sys_id.toString());
}
//Now convert the array to a string and populate to the list field.
var myTargetString = myReferenceArray.toString();
myTargetList = myTargetString;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2021 05:50 PM
Please share your existing script ... it will be easier to modify something rather than start from scratch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2021 05:54 PM
Hi, without specific details of what\where\how you are doing this, it is hard to provide exact details but your basic script might be something like this
var myReferenceArray = [];
//Query your reference data
var mySource = new GlideRecord('mySourceTable');
mySource.addQuery('field', referenceValue);
mySource.query();
//iterate through the results and push records into an array
while(mySource.next() {
myReferenceArray.push(mySource.sys_id.toString());
}
//Now convert the array to a string and populate to the list field.
var myTargetString = myReferenceArray.toString();
myTargetList = myTargetString;