select box - multiple choice - g_form.addOption

JohnMMcLaughlin
Tera Contributor

Hi,

I have a catalog item where one of the variables (it is part of a variable set) will display all assets assigned to a selected user, but then I need the requestor to select only one of the assets, so I would ideally like to use a multiple choice field type, but when I try and use the g_form.addOption() method to add the users assets to the field nothing happens.

 

If I change the field type to a select box the same code works and the assets are added as expected, except the field only shows the first asset and you have to click the drop down arrow to show the rest.

 

Preferred option would be to use the multiple choice field type so how do I dynamically add multiple choice options?

Acceptable alternative would be to use the select box if the field can be expanded automatically, showing all assets.

 

Thanks in advance. 

2 REPLIES 2

Pratiksha Kalam
Kilo Sage

Hi John,

Refer below link will definitely help you,

https://community.servicenow.com/community?id=community_question&sys_id=8e0a8369db5cdbc01dcaf3231f96...

 

If my reply helps you at all, I’d really appreciate it if you click the Helpful button and if my reply is the answer you were looking for, it would be awesome if you could click both the Helpful and Accepted Solution buttons! 🙂


Regards,
Pratiksha

dvp
Mega Sage
Mega Sage

You should be able to achieve it by using a Reference variable and use reference qualifier to display only assets that are related a current user