How to Process User Object Gliderecords coming as inputs to get mails and sys IDs ??

Manikantahere
Tera Contributor

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??

1.png

Screenshot 2025-04-18 230605.png
2.png3.png

1 ACCEPTED SOLUTION

@Manikantahere 

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);

AnkurBawiskar_0-1745227722394.png

 

AnkurBawiskar_1-1745227743059.png

 

AnkurBawiskar_2-1745227794006.png

 

Output:

email array list.gif

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

9 REPLIES 9

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 

approverSysIds  in log and I am not seeing out put as well when I tested. 

Manikantahere_0-1745134352830.png

 

@Ankur Bawiskar  can you try to look this?

 

@Manikantahere 

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);

AnkurBawiskar_0-1745227722394.png

 

AnkurBawiskar_1-1745227743059.png

 

AnkurBawiskar_2-1745227794006.png

 

Output:

email array list.gif

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Manikantahere 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Does this won't work if I forward sysIds or array of glide records objects through script when I calling this script action.