Now to set Requested For via REST API with using the User ID not Sys ID

Lee Franke1
Kilo Contributor

Using the /order_now functionality of the REST API I can create an REQ. In order to set the Requested For, I have to know the sys_id of the user. Is there any way to use the email or User ID and set the Requested For via the REST API?

I'm sure I'm missing something as this seems rather limiting for other applications to have to have the sys id in order to integrate with ServiceNow.

thanks,

lee

1 ACCEPTED SOLUTION

RAHUL YADAV9
Mega Guru

There are2 ways to do it.

1. Scripted REST API in Servicenow where you will get requested for as a string and then glide record the sys_user table to get the sys id of that user and use that when creating the REQ.

 

2. You can write down a before business rule that runs on insert on REQ table and in conditions put your integration user so this will not be applicable for other users and  then glide record the sys_user table to get the sys id of that user and update current.requestedfor.

 

Please let me know in case you need help with scripts.

 

Please mark correct and helpful if this helps.

View solution in original post

2 REPLIES 2

RAHUL YADAV9
Mega Guru

There are2 ways to do it.

1. Scripted REST API in Servicenow where you will get requested for as a string and then glide record the sys_user table to get the sys id of that user and use that when creating the REQ.

 

2. You can write down a before business rule that runs on insert on REQ table and in conditions put your integration user so this will not be applicable for other users and  then glide record the sys_user table to get the sys id of that user and update current.requestedfor.

 

Please let me know in case you need help with scripts.

 

Please mark correct and helpful if this helps.

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Lee,

Unless creating a Scripted REST API, it's necessary to get the user's sys_id using REST Table API. That is, it's necessary to make several API calls.

https://<instance name>.service-now.com/api/now/table/sys_user?sysparm_query=user_name%3D<user id>&sysparm_limit=1 

https://developer.servicenow.com/dev.do#!/reference/api/rome/rest/c_TableAPI