- 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-15-2022 06:26 AM - edited 12-15-2022 06:28 AM
@jaheerhattiwale : I have some doubts. Can you pls clear.
[] For the instance property creation. You are suggesting to add the servicenow prod url in the value field but my REST API is not having the servicenow url. It has some other url value something like this - https://store-api-test.com/blablablablabblaaa
and as per your script complete endpoint will be as below -
restmessage.setEndpoint("https://"+gs.getProperty("<PROD INST NAME PROPERTY NAME HERE>")+"/<REMAINING URL HERE>");
[] Also you are suggesting to add servicenow production value in the property , what about for non-prod ones?
[] for the authentication part. Username and password not stored in the servicenow instance.
We have just hard coded the values in the script to set basic auth
what best we can do to run the same script for PROD and NON-PROD instances to set the non-prod & PROD API and Basic auth ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 06:30 AM
@Rahul84 Ok got it.
In Prod instance name property add "store-api-test.com"
in user id and password properties add the credentials of "store-api-test.com" this site.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 06:46 AM
@jaheerhattiwale : ok, also how we are catering the non-prod API execution becoz we are only adding the prod api url in the property. can you suggest how we are going to cater the non-prod execution with the same script.
Also for the user name and password.
we can directly pass the username and password (hardcoded values) in the property value field ? will this work if we don't have those records in the servicenow instance.?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 07:19 AM
@Rahul84 You just need to change the property values with subprod instance name credentials.
Don't change code at all just update the properties
ServiceNow Community Rising Star, Class of 2023
- 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