- 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 03:54 AM
Hi Vidyapati,
To do that you need to make few changes in the script.
First GlideRecord sys_user table for the passed user name and fetch sys_id of that user and then use that in requested for :-
for example
Extract the username in any variable inside the rest api. Then GlideRecord the user table for that user name/UserId and extract it's sys_id and then assign it to requested_for variable.
Let me know if you need more clarity over this.
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:12 AM
Hi Kamlesh,
Where I can write the script? I dont want to create any staging table. I am directing calling the REST api.
Thanks.
- 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-03-2018 04:03 AM
Thanks kamlesh,
I worked perfectly for me.
Although I have one question - Isn't this change going to affect globally?
Currently I am doing API call only for one catalog item. What if I select other catalog item?
Thanks,
VP