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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2020 01:33 AM
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
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2020 01:44 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2020 02:08 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2020 02:22 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2020 04:22 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader