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.

showing message based on multiple choice selection

omsa1
Kilo Guru

There are 5 questions on a record producer form, i need to show a message based on this 5 fields selection. onchange client script only working when change of a field that is configured. Need help on this. 

 

find_real_file.png

1 ACCEPTED SOLUTION

ggg
Giga Guru

i created 2 fields, q3 and q4.

i have an onchange client script on q3 with the script shown below.

(put the same on q4 and change the field name)

extrapolate from this to your 5 fields.

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

  if (newValue == 'yes'){
      if (g_form.getValue('u_q4') == 'yes'){
          alert('1');
      }
      else {
          alert('2');
      }
  }
    else if (g_form.getValue('u_q4') == 'yes'){
          alert('3');
      }
      else {
          alert('4');
      }
   
}

View solution in original post

5 REPLIES 5

ggg
Giga Guru

i created 2 fields, q3 and q4.

i have an onchange client script on q3 with the script shown below.

(put the same on q4 and change the field name)

extrapolate from this to your 5 fields.

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

  if (newValue == 'yes'){
      if (g_form.getValue('u_q4') == 'yes'){
          alert('1');
      }
      else {
          alert('2');
      }
  }
    else if (g_form.getValue('u_q4') == 'yes'){
          alert('3');
      }
      else {
          alert('4');
      }
   
}