- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2021 09:44 PM
Hi,
I am using the Service Catalog API (namespace : "sn_sc") to create a service request (REQ#) with a request item (RITM#) attached to it using REST API explorer. Below is the request body used ( only mandatory variables for this item is used) ;
{ "sysparm_quantity" : 1,
"variables" : {
"requestor" : "test user",
"project_details" : "test project",
"week_to_unfreeze_time" : "08-03-2021",
"reason_for_unfreeze" : "reason comes here"
}
}
From the above, the request gets created for the user who is sending the request. However, I want to raise this request on behalf of another user. How can this be done?
What I tried :
- Passing the "requested_for" variable both inside and outside of the "variables" field in the request.
- Tried passing the user name and also, the user id in requested_for field.
How can this be done please.
Thanks,
Faiz.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2021 03:34 AM
Please remember this point
1) for reference variable you should always send the sys_id
2) for choice variable always send the choice value
3) for checkbox send true/false
To set the OOB requested_for field on REQ with your user add sysparm_requested_for
{ "sysparm_quantity" : 1,
"sysparm_requested_for" : "4ae3ab0753101200ed11da86a11c0881"
"variables" : {
"requestor" : "UserSysIdHere",
"project_details" : "test project",
"week_to_unfreeze_time" : "08-03-2021",
"reason_for_unfreeze" : "reason comes here"
}
}
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
‎03-23-2021 12:12 AM
Hi
Thanks for the reply. I have tried it, passing the sys_id of different users also. The Requested By field doesn't show anything and when clicked preview icon, it says "no preview available".
However the location field is populated according to the location of the passed user.
Thanks,
Faiz.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2021 12:20 AM
Hi,
the user whose sys_id you are setting has name populated in it?
did you check by inspecting the XML of the record and see what it shows?
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
‎03-23-2021 02:48 AM
Thank you for marking my response as helpful.
If my response helped you please mark it correct to close the question so that it benefits future readers as well.
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
‎03-23-2021 02:56 AM
Hi,
Thanks for the support
{ "sysparm_quantity" : 1,
"variables" : {
"requestor" : "4ae3ab0753101200ed11da86a11c0881",
"project_details" : "test project",
"week_to_unfreeze_time" : "08-03-2021",
"reason_for_unfreeze" : "reason comes here"
}
}
Thanks for helping,
Faiz.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2021 03:02 AM
Did you accidentally marked your own response as correct?
As per your question you required requested_for dictionary field to be set with custom user sys_id and not logged in user sys_id
For that I already shared the solution i.e. what needs to be added to the JSON body i.e. sysparm_requested_for
Please mark my response as correct as I was able to help you.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader