Select Box populated from external web service
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2017 01:25 PM
Hi,
I'm brand new to ServiceNow and trying to figure out if dynamic select box is possible.Here is the end result I'd like to have.
A select box on my form which has choices, lets say A,B,C,D.
I currently do not have these choices stored in a table; they need to be dynamically pulled for each request from an external web service. I can do a REST call to the external web service and receive JSON back with the list of choices.
The approach I've looked at so far is:
-create a workflow that executes rest message and inserts the resulting output variables into the table. Schedule the workflow to run every 30 minutes.
I'm wondering if there is a way to just have this done at request time? When the user loads the form and clicks on the select box, the call is executed and resulting array is populated. This way it's always up to date.
Is there a way to accomplish this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2017 02:32 PM
I think you're on the right track with the outbound REST message. I think you have 2 options:
1. Have the select box get its choices from a table that you refresh periodically, like you said. This is the simpler option, and the more maintainable one, in my opinion.
2. Have the request form use a Client Script that uses GlideAjax to ask the server to run a script which runs the REST request, reads it, and returns the list choices to the client as a response. The client, now knowing what the choices are, can actually put them into the select box using the GlideForm.addOption method.
Option 2 seems pretty complicated - I think you could realistically achieve the same effect using an aggressive refresh schedule with option 1 (i.e. refresh the choices every 5 minutes). You would use a scheduled job, instead of a workflow, to do this. If your remote resource is slow or unavailable, having the choices cached in ServiceNow would make for a better user experience when it comes to actually filling out the form.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2017 03:33 PM
I would write an onLoad client script and make GlideAjax call to call the outbound message in the script include.