Using gs.getUserID() within .includes

gunishi
Tera Guru

Hi there, 

 

I am using gs.getUserId() in a condition for a UI action. 

 

What does this method return, is it the sys_id of the user?

 

If so will this work if I assign the variable and then use it in /includes as below:

 

var user = gs.getUserID();

 

approvers.includes(user);

 

 

Will this return true or false or just break? and if it breaks can I use the following syntax:

 

gs.getUserID().toString();

Thank you

G

2 ACCEPTED SOLUTIONS

@gunishi 

yes it returns sysId as string so no need to use toString() function

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

@gunishi 

Sys_id itself string value.

View solution in original post

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

@gunishi 

gs.getUserID() returns sys_id of logged in user

what does approvers indicate here? I believe it should be an array

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

Hi @Ankur Bawiskar 

 

Thanks for your response. Approvers is indeed an array and I need the sys_id to be in string format. Will gs.getUserID().toString(); work?

 

Kind regards, 

G

@gunishi 

If you want the display value then use.

gs.addErrorMessage(gs.getUserName());
admin.PNG

Hi @shubhamdubey 

 

Thank you for your response. I just need the sys_id but as a string. How would I about this?

 

Would gs.getUserID().toString(); work?

 

Kind regards, 

G