Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get List of possible options on choice variable field?

Zod
Giga Guru

HI,

I have a select box variable and 'remove' some options via a catalog client script on load. 

Now I need to be possible to list the remaining "possible" options via a catalog client script.

How to?

Was was hoping it works this way ... 

 

var values = [];

var sel = g_form.getElement('<variablename>');

for (var i=0, n=sel.options.length;i<n;i++) {

gs.info(sel.options[i].value);

}

.. but this seems not to work.Type Error ...  "sel is undefined" ... 

Any idea?! Thank you! 

14 REPLIES 14

 

Code now: 

find_real_file.png

find_real_file.png

Its a scoped catalog item ... maybe this is an issue?

Also works in my PDI.;-(

No Idea what might be wrong here ... 

https://community.servicenow.com/community?id=community_question&sys_id=245c8f65db9cdbc01dcaf3231f96...

 

Just seeing that I tested in PDI via "TEST IT" .. not via the serviceportal. In Serviceportal, I also get an error.

Saying here, that property options could not be read. 

 

https://docs.servicenow.com/bundle/london-application-development/page/script/client-scripts/referen...

 

The methods getControl()getHelpTextControl()getElement(), and getFormElement() are deprecated for mobile devices. For information on using GlideForm for mobile, see Mobile Client GlideForm (g_form) Scripting and Migration .