Creating a new incident form field with drop down options that's dependent on another choice

stephenjsmith
Tera Contributor

Let me know if this would be better in another forum:

I've had a look at several tutorials but they seem to be more about Categories and Sub-Categories and I suspect this is fairly straightforward once you know how:

I would like to create a new mandatory field for Agents on the incident form that presents 2 options and then a new drop down list appears for each option, depending on which option is chosen.

I'm fine creating new string fields but trying to work out how to make them appear dependent on a choice list.

e.g.

1. Choose from a new field - option A or Option B

2. Choose option A - new list appears below with option A choices - 1,2,3

3. Choose option B - new list appears below with option B choices - 1,2,3

 

The result will be an incident form recording failure demand and value demand and the type , separate from category and subcategory. Any advice is much appreciated

1 ACCEPTED SOLUTION

Hi @stephenjsmith ,

It is not possible by form design. If we don't want to write the script then we can create 3 Ui polices to achieve this.

From Filter navigation go to system ui> select ui policies> click new

1:

Screenshot 2023-01-20 at 7.14.26 PM.png

2:

Screenshot 2023-01-20 at 7.14.55 PM.png

3:

Screenshot 2023-01-20 at 7.15.29 PM.png

View solution in original post

9 REPLIES 9

kalyan13
Tera Guru

Hi @stephenjsmith ,

You need to create 3 choice fields on the form and next you need to write onload client script and onchange client script.

onload client script:

 

function onLoad() {
//Type appropriate comment here, and begin script below

g_form.setDisplay('u_option_a', false);
g_form.setDisplay('u_option_b', false);

}Screenshot 2023-01-20 at 6.16.21 PM.png

Onchange Client script:

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

var a = g_form.getValue('u_field_1');
alert(a);

if (a == '1') {
g_form.setDisplay('u_option_a', true);
g_form.setDisplay('u_option_b', false);
} else {
g_form.setDisplay('u_option_a', false);
g_form.setDisplay('u_option_b', true);
}


}


Screenshot 2023-01-20 at 6.18.08 PM.png

Mark the solution as helpful and correct if it solves your issue.

 

Regards,

Kalyan
 

komalkp
Tera Contributor

Not able to Create dropdown list on incident form using client script. can anyone please help me

 

Hi @komalkp , 

 

Can i know what issue your facing. 

 

Regards, 

Kalyan

stephenjsmith
Tera Contributor

Thank you for sharing this solution. I was hoping I could do it without coding in the Form Design interface, I it will be a bit more complex than I thought 🙂