API call through Onload of a catalog form

Rahul84
Tera Contributor

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 !!

1 ACCEPTED SOLUTION

@Rahul84 Have you tried this? if yes then please close the thread by marking all correct answers

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

View solution in original post

46 REPLIES 46

Ankur Bawiskar
Tera Patron
Tera Patron

@Rahul84 

should be easy enough.

1) onLoad catalog client script with GlideAjax

2) then add the choices via g_form.addOption()

Sharing link for your help

How to create an outbound REST API using Catalog Client Script

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

Thanks for the reply , could you please help us in the detailed explanation/solution of this requirement.

So it will be easy for me to start with.
1). onLoad catalog client script with GlideAjax

<< What exactly I need to do in this ?>>
Could you please help with the step by step explanation 
Thanks !

 

@Rahul84 

you can check below links on how to call REST Message/SOAP message to call the API in server side

https://servicenow-docs.readthedocs.io/en/latest/REST_Messages/ 

https://dxsherpa.com/blogs/create-a-rest-message-how-to-read-the-docs-integration-part-2/ 

what did you start with?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Rahul84 

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader