Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Make fields visible on form Based on another field

ketki_j
Tera Contributor

Hi,

I want to make my fields visible on form depending a variable "Disponent" whose type is "list".

find_real_file.png

Reference to this fields are three fields PM, MM, PP. Depending on them I have three fields on form PM users, MM users, PP users which should be displayed when PM, MM, PP respectively are selected into Disponent.

find_real_file.png

And here is my client script (on change of field Disponent)-

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

  var x=g_form.getValue('u_disponent');

      if(x=='')

  {

g_form.setVisible('u_pm_user',false);

  g_form.setVisible('u_mm_user',false);

  g_form.setVisible('u_pp_user',false);

  }

if(x=="296388e1db7332002667d001cf961996")

{

alert("PM user")

     

g_form.setVisible('u_pm_user',true);

g_form.setVisible('u_mm_user',false);

g_form.setVisible('u_pp_user',false);

}

if(x=='31334ce5db3332002667d001cf961926') // MM

{

alert("MM true")

g_form.setVisible('u_pm_user',false);

g_form.setVisible('u_mm_user',true);

g_form.setVisible('u_pp_user',false);

}

if(x=='8f63c42ddb3332002667d001cf961948') //PP

{

alert("PP true")

g_form.setVisible('u_pp_user',true);

g_form.setVisible('u_mm_user',false);

g_form.setVisible('u_pm_user',false);

}}

1 ACCEPTED SOLUTION

In the UI policy, your condition would be:



Disponent | contains | (user)



Here's an example on the incident watch list field I just built.


find_real_file.png


View solution in original post

6 REPLIES 6

tanumoy
Tera Guru

What is the issue you are facing..???


ketki_j
Tera Contributor

Hi Tanumoy,



The issue is- When there are multiple values selected, still it shows the field of only first selected value.


find_real_file.png