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

Manikantahere
Tera Contributor

@Ankur Bawiskar  can you pls look into this if possible? 

Ankur Bawiskar
Tera Patron
Tera Patron

@Manikantahere 

what's your actual business requirement?

did you give correct output type for your action?

what input you are passing and what you require?

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

You can see below link  more or less I am having same  business logic and script. I have used your correct script only However my requirement slightly changed so that I have changed  inputs from reference to list user and list group so that people can select multiple users or multiple groups.

also while they are passing parameters some times they can push the values to action through input script instead directly passing the values.?

This is where I am trying to work on it.

And out puts are remains string fields only as they just pass out emails and sys_Ids as outputs.



https://www.servicenow.com/community/developer-forum/action-out-put-is-not-giving-expected-output/m-...


@Manikantahere 

so in your above action what's not working?

I don't know what you action takes and what debugging did you perform?

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