- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2025 10:47 AM
I may get approvers as below by selecting them or through script.
I need to process them and get the User object sys ids and mails ? But I am getting empty list when I tried for sysIDs?
and also can I pass list of sysIds through script or do i need to pass there also objects and process them with same script??
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2025 02:32 AM
so your requirement is you are passing list of user records and then want to get emails for all those?
if yes then this worked for me
1) since you are passing a list of GlideRecord objects, simply iterate that using while
(function execute(inputs, outputs) {
// ... code ...
var userListRec = inputs.mylist;
var emailArr = [];
// iterate the object
while(userListRec.next()){
emailArr.push(userListRec.email.toString());
}
gs.info('emailArr' + emailArr.toString());
outputs.emailarr = emailArr.toString();
})(inputs, outputs);
Output:
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2025 12:34 AM
If you see there I am trying to process the list of users that people selected and get the emails but unfortunately I am not getting anything when printed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2025 02:14 AM
@Ankur Bawiskar can you try to look this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2025 02:32 AM
so your requirement is you are passing list of user records and then want to get emails for all those?
if yes then this worked for me
1) since you are passing a list of GlideRecord objects, simply iterate that using while
(function execute(inputs, outputs) {
// ... code ...
var userListRec = inputs.mylist;
var emailArr = [];
// iterate the object
while(userListRec.next()){
emailArr.push(userListRec.email.toString());
}
gs.info('emailArr' + emailArr.toString());
outputs.emailarr = emailArr.toString();
})(inputs, outputs);
Output:
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2025 03:31 AM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2025 03:34 AM
Does this won't work if I forward sysIds or array of glide records objects through script when I calling this script action.