How to show a Drop down list for each row in List?

hay
Tera Expert

Hello,

   I am working on a custom scoped app and using UI Builder. I am trying to show a drop down list column with values from a reference field. The use will choose a specific value from this Drop down list which I will need to access and save it in another table. I can't find anyway to do that from UI builder. Is that even possible with SN UI builder OOB? 

Thank you for your help.

 

 

2 REPLIES 2

Anish Reghu
Kilo Sage
Kilo Sage

Yes, it is possible to use the ServiceNow UI Builder to create a dropdown list column that allows users to select a value from a reference field and save it in another table.

To do this, you will need to use the List Control component in UI Builder to create the dropdown list column. When configuring the List Control component, you can specify the reference field that you want to use as the source for the dropdown values.

Once the dropdown list column has been created, you can use a UI action or a client script to capture the selected value when the user submits the form. To save the selected value in another table, you can use a server-side script (e.g., an onSubmit script or a script include) to insert a new record into the target table with the selected value.

 

 

Here is an example of how you can use the ServiceNow UI Builder to create a dropdown list column that allows users to select a value from a reference field and save it in another table:

  1. In UI Builder, create a new form and add a List Control component to it.

  2. In the List Control configuration, select the reference field that you want to use as the source for the dropdown values. For example, if you want to allow users to select a value from the "Department" reference field, you would select "Department" as the Data Source for the List Control.

  3. In the Display field, specify which field from the reference record should be displayed in the dropdown list. For example, you could select the "Name" field to display the name of the department in the dropdown.

  4. In the Value field, specify which field from the reference record should be used as the value for the selected option. This value will be saved in the target table when the form is submitted.

  5. Add a UI action to the form that will be triggered when the user submits the form. In the UI action script, use the following code to get the selected value from the dropdown list column and save it in the target table:

 

 
 

 

// Get the selected value from the dropdown list column
var selectedValue = g_form.getValue('department');

// Insert a new record into the target table with the selected value
var targetRecord = new GlideRecord('target_table');
targetRecord.department = selectedValue;
targetRecord.insert();

 

 

Kindly mark the response as Correct or Helpful.

Cheers,

Anish

 

hay
Tera Expert

Thank you @Anish Reghu  sorry I just realized that I missed one thing in my question. The drop down list will not be in a form it will be a column in a simple list control in UI builder. In the screen shot I need the user field to be a drop down list. 

hay_0-1673228107034.png