The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Change the search box to a select box

Jieun Jeong
Giga Contributor

Hi, I'm trying to create a selectbox that changes depending on the selection values in another column.

So I entered the Attributes, Reference qual value and selected Choice value 'Dropdown With --None--'.

But It's still a search box. How Can I change it to select box?

find_real_file.png

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Hitoshi Ozawa
Giga Sage
Giga Sage

Following steps will add a select box on Contract form.

  1. Open Contract form
  2. Select hamburger icon > "Configure" > "Form Design"
    find_real_file.png
  3. Select "Field Types" tab and drag and drop "Choice" to the form
    find_real_file.png
  4. Select "Field Choice" icon
    find_real_file.png
  5. Edit Label and Name fields
    find_real_file.png
  6. Scroll down and edit/add all choices to make available
    find_real_file.png

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

If it's a reference field then why would it have choice with Drop down None?

Regards
Ankur

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

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Jieun,

Is the field suppose to reference values from other table or is it a selection based on defined choices?

Dynamic pull-down list can be created using a field of type "reference" that populates choices from a table. In this case, reference qualifier can be used to dynamically change available choices in the pull-down.

The other option is to create a field of type "Select Box". In this case, choices are defined in a field. onChange() Client Script can then be written to dynamically change available choices depending on other fields.

Hitoshi Ozawa
Giga Sage
Giga Sage

Following steps will add a select box on Contract form.

  1. Open Contract form
  2. Select hamburger icon > "Configure" > "Form Design"
    find_real_file.png
  3. Select "Field Types" tab and drag and drop "Choice" to the form
    find_real_file.png
  4. Select "Field Choice" icon
    find_real_file.png
  5. Edit Label and Name fields
    find_real_file.png
  6. Scroll down and edit/add all choices to make available
    find_real_file.png

To dynamically change available choices, create a onChange() script on u_parent field.

  1. Click on "Configure" > "Client Script"
    find_real_file.png
  2. Click on "New"
    find_real_file.png
  3. Enter script
    sample:
    function onChange(control, oldValue, newValue, isLoading, isTemplate) {
        if (isLoading || newValue === '') {
            return;
        }
        if (newValue == 'a9b438c097ea011086d3b4b3f153af9d') {  // sys_id of record in u_parent table
            g_form.addOption('u_branch', 'branch1', 'branch1');  // add option branch1
    		g_form.addOption('u_branch', 'branch2', 'branch2');  // add option branch2
        } else {
    		g_form.removeOption('u_branch', 'branch1');          // remove option branch1
    		g_form.addOption('u_branch', 'branch3', 'branch3');  // add option branch3
    	}
    }​

    find_real_file.png

 Execution result:

case 1. If condition in script satisfied. "branch1" and "branch2" added as an option

find_real_file.png

case 2: If condition not satified. "branch1" removed and "branch2" added.
find_real_file.png