Show/Hide choices of field based on selection of another field choice

Evan2
Kilo Guru

Hi Friends,

I an trying to show/hide choice of request type based on the choice selected for the field Select request Item on service portal.

Example:-

If Select request Item= Card Swipe Unit

then- Request Type should only show Install card swipe unit as choice.

PFB the screenshot for reference and help me how to achieve this.

find_real_file.png

Regards,

Evan

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Evan,

you would require onchange client script on the select item variable; sample script below

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading) {
      return;
   }

g_form.clearOptions('request_type');

if(newValue == 'Card Swipe Unit'){

g_form.addOption('request_type', choicevalue, choiceLabel);
g_form.addOption('request_type', choicevalue, choiceLabel);

}

}

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

View solution in original post

6 REPLIES 6

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Is request type for example a Reference type variable? And is there a relation with the Request type If so, you could use a reference qualifier? Have you tried that / investigated that already?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Evan,

you would require onchange client script on the select item variable; sample script below

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading) {
      return;
   }

g_form.clearOptions('request_type');

if(newValue == 'Card Swipe Unit'){

g_form.addOption('request_type', choicevalue, choiceLabel);
g_form.addOption('request_type', choicevalue, choiceLabel);

}

}

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

Hi Ankur,

 

I have tried your script but no changes has been seen.

PFB the script i have used-

find_real_file.png

Regards,

Evan

Hi Evan,

So is it giving the alert at line 12?

Did you check the choice value for request_type variable?

Regards
Ankur

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