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

What is the script for that which i have to create?

Hi Hemanth,

You will require onChange client script on that drop down field/variable

Script Include which is client callable

Few links for you to get started

https://community.servicenow.com/community?id=community_article&sys_id=9f7ce2e1dbd0dbc01dcaf3231f961...

https://community.servicenow.com/community?id=community_question&sys_id=907dcbe9db9cdbc01dcaf3231f96...

Regards
Ankur

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

Hi ankur,

Yes, Giving you an example condition.

Have a list of servers in the choice field. Users should be able to select only 20 servers in the list for a single catalogue request,

Vishakha
Mega Guru

Hi Hemanth,

Check this:

Display a reference field as a choice list

 
Madrid

You can display a reference field as a choice list instead of opening a lookup window.

Before you begin

Role required: personalize_dictionary

Procedure

  1. In the form, right-click the label for the reference field and select Configure Dictionary.
  2. In the Choice List Specification section, select one of the following options in the Choice field.
    • Dropdown with --None--
    • Dropdown without --None--
  3. Right-click the form header and click Save.
  4. Under Related Links, click Advanced view.
  5. In the Attributes field, add the following attribute, separated from other attributes by a comma.
    ref_auto_completer=AJAXReferenceChoice
  6. Click Update.
    The form reopens, with the reference field as a choice list.
    Reference choices
    Note:

    The glide.ui.max_ref_dropdown system property determines whether a reference field is displayed as a choice list or a reference icon. When the number of available choices exceeds the value of this property, a reference icon displays instead of a choice list. The default value of this property is 25. This property affects the entire instance, however you can override this property on an individual field by using the max_ref_dropdown dictionary attribute. Modifying dictionary attributes requires the personalize_dictionary role.

    The glide.xmlhttp.max_choices system property determines how many choices display on a choice list. This property has a value of 15 by default, however, when the property is not present on the instance, the instance uses a hard coded value of 10.

     

    Also refer below thread:

    https://community.servicenow.com/community?id=community_question&sys_id=6be643e5db1cdbc01dcaf3231f96...

     

    If it helps then please mark my answer Correct and Helpful.

    Vishakha

Ali Shaikh1
Giga Expert

Hi Hemanth,

 

  if (isLoading || newValue === '') {

 

          return;

 

    }

 

var val = g_form.getValue('fieldname');

 

  alert(val);

 

  if(val=='value you want')

 

  {

 

  alert('inside');

 

  g_form.removeOption('fieldname', 'value');

 

  }

 

If this type of your requirement then please mark answer as Helpful.