- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 04:59 AM
Hi Developers/ @Ankur Bawiskar
This is related to one of the tricky requirement which I need to build.
I need to call an API on the load of a catalog form and the response I need to store in one of the catalog form field which is a drop down options field.
Please let me know how I can achieve this type of requirement.
Step by Step explanation would be helpful and also a type of sample code.
Thanks in Advance !!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2022 02:26 AM
@Rahul84 Have you tried this? if yes then please close the thread by marking all correct answers
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2022 05:36 AM
@Rahul84 Did you try that?
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2022 05:29 AM
yes @jaheerhattiwale I have tried and solution is working fine. Thanks a lot for the help.
Just one issue. I cannot use the hard coded script to set the rest message things in the script include.
I need to call rest message from SI. But one challenge here is how to set query parameter for the current logged in user. "gs.getUser().getName()".
Any way to set this in REST Message as query parameter instead of using script in SI?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2022 06:04 AM
@Rahul84 Don't add the HTTP Query Parameter on Rest message as you added in the image you posted. Remove it from there as you have added below line in script include.
sm.setQueryParameter("userid",gs.getUser().getName())
This line takes care of that.
Can you please mark all the answers in this question as correct answer.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2022 06:14 AM
@jaheerhattiwale : can we use gs.getUser().getName() directly in rest message instead of using this in script?
Instead of the script like sethttpmethod,setendpoint , setqueryparamter.
We are planning to call the rest message directly inside sn_ws.RESTMessageV2();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2022 06:17 AM
@Rahul84 No. You have to use one or the other function in script include.
You can write the script directly in the rest message query param.
If you add variable there like ${userid} and generate auto variables the you must use setStringParameter() function instead of setQueryParameter() function.
So its ok to use setQueryParameter() function
ServiceNow Community Rising Star, Class of 2023