how to get the sysid for a user using the username ex. like i have deepak.rawat and i want to pull the sysid of this

deepak rawat1
ServiceNow Employee
ServiceNow Employee

how to get the sysid for a user using the username ex. like i have deepak.rawat and i want to pull the sysid of this .

if there a way to pull the information for the sysid of a assignment group as well ? i trying to create incident with rest where i sending the username and assignment gourp , now incident is getting created but call and assigment group is not getting populated. i guess that is because i need to find the sysid of both for population so i need to find the sysid of both

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Deepak,

you would require to send sys_id of those values.

Also those records with that sys_id should be present in the other instance.

if you have the user_name and want to get the user sysId then try this in server side script

var sysId = gs.getUser().getUserByID('deepak.rawat').getRecord().getValue('sys_id');

gs.info(sysId);

Regards
Ankur

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

hi ankur ,

yes i need the sys-id , that is what i am asking is there a way i can get the sys-id from the caller name (like deepak.rawat) or with assignment group with in the script . i tried use gs.getUser().getUserByID() but its giving me a error so is there a way i can pull that information with the script dynamically using the user id or assignment group name 

yes ankur i tried to user gs.getUser().getUserByID("deepak.rawat") but this function is not avialable in the script under scripted rest api script . i ma i doing something wrong or is there other way to find that info.

@deepak rawat 

scripted rest api is server side so it should allow you.

But I think your scenario is different. you want to set the caller and group based on sys_id.

so you would require to get the user record and the group record for those sys_ids then you need to populate the details in incident

Regards
Ankur

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