- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2018 03:28 AM
Hi,
I am trying to create catalog request using this REST API - /api/sn_sc/servicecatalog/items/{sys_id_item}/order_now.
Catalog is getting created successfully when I am passing this query parameter -
{"sysparm_quantity":"1",
"variables": {"requested_for":"c72b38bb4f59a600db4315924210c745"}
But instead of sys_id of 'requested_for', I want to pass name of the user.
How I can convert name into sys_id before inserting into the table.
thanks in advance!!
Vidyapati
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2018 09:54 PM
Hi Vidyapati,
You need not to create any staging table. Please follow the below steps to meet your requirement :-
1. Go to table "sys_ws_operation" and open "Buy Item" record.
2. Click on the "here" text to edit the script as shown below in the screen shot :-
3. Scroll down to the script area. Below is the screen shot of the change that you need to make in the script. Add the code which is inside red box in your script and save the changes.
4. Now call your REST api and test.
Let me know if this works for you. However I tested this and is working on my instance.
Please mark helpful/correct if this solves your issue/requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2018 04:17 AM
HI,
Vidyapati Mishra wrote:
How I can convert name into sys_id before inserting into the table.
How can you get the sys_id of the record, unless its fetched?
If sys_id is to be passed it has to be static.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2018 04:25 AM
Hi as you are direct Rest API there is no need for conversion to sys_id
You can send the name of the user in the payload, if the exact name matches in the user table the record is created with the users name. If not the requested for value will be empty.
Please like, Mark helpful/Correct based on the impact of the response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2018 11:35 PM
Hi Vidyapati,
Effect of this change is limited to REST call only and it will work for all the catalog items. If you send any user name, it will work. Even if you send sys_id of the user it will work.