- 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 04:07 AM
@jaheerhattiwale : Yes I have tried this and logic is working but there are some issues.
Found one issue/scenario.
[] Suppose I have loaded the catalog form with my name ( logged in with my id). So it will give me the response from the API for my id and we are storing the responses in one of the field. This is working fine.
But If I have loaded the form with my id and changing the "requested for" to some other name then , the drop down options are getting added. In the drop down field ( options available for the user which is loading the form+ Requested for user ( if changing to some other user name)).
[] Also currently the script is getting executed two times in backend. In logs the same things are getting printed two times at the same time with a difference if 2/3 secs.
Desired scenario :
If I am a loading the catalog form with my id , then it will show the API response for my id and same will be stored in drop down field.
But if I am changing the value of "Requested for" field , then the drop down field should only show the API response of the userid which is selected in "Requested for" field. It should clear out the choices for the previous user. Currently it is adding the choices.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 04:25 AM - edited 12-15-2022 04:25 AM
@Rahul84 In both the client script add below line before glideajax call.
g_form.clearOptions("<DROP DOWN FIELD NAME HERE>");
Please mark all answers on this question as 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 04:29 AM
before line number 5? or suggest the exact line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 04:40 AM
@Rahul84 Before line no. 5
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 05:22 AM
Thanks a lot @jaheerhattiwale . Solution is working fine.
can you help with the below solution?
how we can set the endpoint and basic auth credentials based on the environment.
As of now I have the added the endpoint and credentials for non-prod in the script but for production movement how to change the endpoint and credential for prod ? and we need to have these non-prod endpoint and credentials in the script becoz need to test the same changes on test instance as well.
Thanks !