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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

So you are having 5 fields and hence 5 onChange client scripts for this.

Are they not working as expected?

What is the desired outcome?

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

omsa1
Kilo Guru

Hi Ankur,

 

Based on multiple choice selection , i want to show a message. but the onchange client script only work when change one field value as we set in variable name.How can i do this?

find_real_file.png

Hi,

So in that case you would require 5 onchange client scripts; no other option I could see

or else show them 5 messages in onSubmit based on value selected in each variable

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

siva_
Giga Guru

You can even have an onchange client script on the last field . On change client script of yours triggers on a particular field change but you can access all the values of other fields as well right , so that you can compare and display messages accordingly. 

Hope this helps 

 

Mark this response as correct if that really helps

 

Thanks,

Siva