If Q1 is Yes and Q2 is No and Q3 is No then i need to display q4 with some value .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 09:56 PM
Hello Everyone,
If Q1 is Yes and Q2 is No and Q3 is No then i need to display q4 with some value . Like this i have 5-6 probability scenarios. i have used Client scripts. How ever few scenarios are not working and for few the Q4 value is not getting cleared. Can anyone help me on this?
Hopefully looking for possible solution, Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 10:05 PM
you will require multiple onChange client scripts
1 for Q1, another for Q2 and another for Q3 and in each of those client scripts you need to check what's the value of other 2 variables and based on that show Q4 with some value
share your 3 onChange client scripts here
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 10:08 PM
How to write these scripts any script for reference?
Because i have
Yes No No
Yes Yes No
Yes Yes Yes
No No No
Yes No Yes
No Yes No
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 10:13 PM
I already informed you will require 3 onChange and handle all the combinations
something like this, please enhance it for your case
Script 1: Q1 onChange
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
checkConditions();
}
function checkConditions() {
var q1 = g_form.getValue('Q1');
var q2 = g_form.getValue('Q2');
var q3 = g_form.getValue('Q3');
if (q1 == 'Yes' && q2 == 'No' && q3 == 'No') {
g_form.setValue('Q4', 'Some Value');
} else {
g_form.clearValue('Q4');
}
}
Script 2: Q2 onChange
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
checkConditions();
}
function checkConditions() {
var q1 = g_form.getValue('Q1');
var q2 = g_form.getValue('Q2');
var q3 = g_form.getValue('Q3');
if (q1 == 'Yes' && q2 == 'No' && q3 == 'No') {
g_form.setValue('Q4', 'Some Value');
} else {
g_form.clearValue('Q4');
}
}
Script 3: Q3 onChange
function onChange(control, oldValue, newValue, isLoading) { if (isLoading || newValue == '') { return; } checkConditions(); } function checkConditions() { var q1 = g_form.getValue('Q1'); var q2 = g_form.getValue('Q2'); var q3 = g_form.getValue('Q3'); if (q1 == 'Yes' && q2 == 'No' && q3 == 'No') { g_form.setValue('Q4', 'Some Value'); } else { g_form.clearValue('Q4'); } }
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 10:22 PM
With the help of these client scripts will cover 3 scenarios, how about the remaining 3 scenarios. Need to create 3 more client scripts?