How to dynamically populate multi‑select rule options in a Catalog Item using data from an API

srikanthvan
Tera Contributor

I’m building a Catalog Item where I need to pull data from an external API. I’ve already created the REST Message and HTTP Method, and I'm successfully able to fetch data of first 2 variables using a Script Include and a Catalog Client Script.

My Catalog Item has three variables:

  • Selection_of_site
  • prompt_selection
  • rules

The “rules” variable needs to display values returned from the external API based on selection of the site. The challenge is that the API can return dynamic values and the user must be able to select multiple rules.

However, the Catalog Item does not support a "(multi‑select choice)" variable type natively.

 

Please provide the information, How to configure it.

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron

@srikanthvan 

you can have either of this approach

1) Approach 1 -> create custom table to hold the values returned from API and use List Collector type variable so that user can select multiple values

OR
2) Approach 2 -> create variable of type Custom with label and use widget to render those values and allow multi-select there

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

@srikanthvan 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

6 REPLIES 6

VishalC3
Kilo Guru

HI @srikanthvan 

 

You can write the Selection_of_site response to a custom table and then use "list collector" type variable pointing to the custom table. List collector gives you ability to select multiple values at once, you can use these as input to your second API call to get response accordingly.

 

Let me know if custom table creation is not desirable and you need alternate solution.

 

Thanks,

Vishal 

 

Thanks,

Vishal

srikanthvan
Tera Contributor

Hi Vishal, Currently I'm creating variable of type Custom with label and using widget to render those values and allow multi-select there, can you help me to provide the scripts such as(HTML, CSS, client controller, server script, script include and catalog client script )