- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2023 01:12 AM
Hi all,
We were wanting to populate the recipient list in Targeted communication using script.
We wrote a script mimicking the object required to put output from the function, but its not returing proper data in the recipient list.
(In background script-its able to return an object format as specified in the script's comment section
Has anyone tried it or can direct to proper script object to return etc?
Sample Script added in the script section:
(function() {
//This script is used to upload recipients to the recipients list based on type chosen
//Example:
//Script should have the type as the 'key' and array of sys_ids corresponding to the type as the values.
//internal => sys_user
//var obj = {'internal' : ['sysId1','sysId2','sysId3']};
//return obj;
//var obj = {};
var existingTranslationsArr = [];
var grTrans = new GlideRecord('sys_user');
grTrans.addEncodedQuery('user_nameISNOTEMPTY^active=true');
grTrans.setLimit(10);
grTrans.orderByDesc('created');
grTrans.query();
while (grTrans.next()) {
existingTranslationsArr.push(grTrans.getValue('sys_id'));
}
var obj = {
'internal': existingTranslationsArr
};
//gs.info(JSON.stringify(obj));
return obj;
})();
The recipients which this script is ultimately adding is also attached in the attachment- which seems to be blank users, and also I specified 10 rows, it brings 6 rows. Not sure on that part as well...
If someone can help on this?
Solved! Go to Solution.