Can you dynamically generate a drop-down list with values from an call to an external API?

courtneyrichard
Giga Contributor

Is it possible to have a field's choice list dynamically populated from an API call?

1 ACCEPTED SOLUTION

Alikutty A
Tera Sage

Yes, You can do this using Ajax calls.



You can write an onLoad client script, that calls an Async Glide Ajax which retrieves the requires choices from your API. For eg if REST API, then you require the Rest Message to get values from an external system. The values can be returned and updated on the choice field using g_form.addOption();



Thank You


Please Hit Like, Helpful or Correct depending on the impact of response


View solution in original post

4 REPLIES 4

Alikutty A
Tera Sage

Yes, You can do this using Ajax calls.



You can write an onLoad client script, that calls an Async Glide Ajax which retrieves the requires choices from your API. For eg if REST API, then you require the Rest Message to get values from an external system. The values can be returned and updated on the choice field using g_form.addOption();



Thank You


Please Hit Like, Helpful or Correct depending on the impact of response


That did it.


Thanks Alikutty.


Hi Courtney,



If I have answered your question, can you please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.



If you are viewing this from the community inbox you will not see the correct answer button.   If so, please review https://community.servicenow.com/docs/DOC-5601



Thank You


Please Hit Like, Helpful or Correct depending on the impact of response


Hi Courtney,

I know its an old post.I have similar type of requirement.Can I have teh script here.

 

Thanks in advance.

 

Regards,

Afifa