How to set a limit for the choice field?

Hemanth38
Kilo Contributor

Hi

How can we set a limit to select a particular choice in the choice field?

11 REPLIES 11

Priyanka Chandr
Mega Guru

Hi,

Use on load client script and make use of g_form.removeOption method to remove the choices as per your need.

Refer below link that will help you to write script

https://community.servicenow.com/community?id=community_question&sys_id=44af0365dbdcdbc01dcaf3231f96...

https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/script/client-scripts/concept/cl...

Kindly mark it correct and helpful if it is applicable.

Thanks,

Priyanka

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Hemanth,

Are you saying based on some condition the choices should be added/removed? if you could explain in detail

Regards
Ankur

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

Yes, i have a field name as TIME which contains choices of "10 to 12", "12 to 2" and "2 to 4".

EX: If 10 user select a choice as "10 to 12", then no others can't able to select that choice. And notification pop up message has to come that "This time slot has filled, please select another time slot. Thank you". We also get to know that we can do that with out scripting. Can you explain?

Thanks

 

Hi Hemanth,

So you have 3 drop down choices for time-slot which user can select

Are you storing in any table which slot is open and which is filled? if yes then you can query that table with this slot and check if it is empty or filled and show alert

Use combination of Script Include and GlideAjax with onchange client script

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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