- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2019 01:36 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2019 07:14 AM
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');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2019 01:48 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2019 12:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2019 12:29 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2019 12:53 AM
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