- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 12:19 PM
I have a catalog client script so for the question 'What is the nature of your request?' is 'Temporary Alternate Approver' then the question 'Please indicate where the approver needs to be updated' auto populates to 'All Departments' and becomes read only. This is the onChange catalog client script i have: (Which works fine)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 12:39 PM
Hi @Jen11
The issue here is because of 2 client scripts that work on same field.
What happens here is,
The else loop in first client script holds true for the if loop in the second client script.
Lets take your 1st script
if (newValue == "Temporary Alternate Approver")
The opposite of this is (newValue ! = "Temporary Alternate Approver"). Now check the else loop of 1st client script which depicts that newValue can be "Add Approver to Workflow" as well.
That is why you should combine both the scripts and make 1 client script with if and else ladder structure.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 12:39 PM
Hi @Jen11
The issue here is because of 2 client scripts that work on same field.
What happens here is,
The else loop in first client script holds true for the if loop in the second client script.
Lets take your 1st script
if (newValue == "Temporary Alternate Approver")
The opposite of this is (newValue ! = "Temporary Alternate Approver"). Now check the else loop of 1st client script which depicts that newValue can be "Add Approver to Workflow" as well.
That is why you should combine both the scripts and make 1 client script with if and else ladder structure.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 01:03 PM
@Ashutosh C J - I thought that would be the case. Would you be able to help me with the script please? How can i combine both?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 07:51 PM
@Jen11
Please use this code
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == "Temporary Alternate Approver") { //replace bac with Temporary choice value
g_form.setValue("u_approver_needs_updated", "All Departments"); //replace s2 - select box 2 variable name and PQR with All Department' value
g_form.setReadOnly("u_approver_needs_updated", true); //replace s2 with select box varibale name
}
else if (newValue == "Add Approver to Workflow") { //replace bac with Temporary choice value
g_form.setValue("u_approver_needs_updated", "Specific Department(s)"); //replace s2 - select box 2 variable name and PQR with All Department' value
g_form.setReadOnly("u_approver_needs_updated", true); //replace s2 with select box varibale name
} else {
g_form.setValue("u_approver_needs_updated", "");
g_form.setReadOnly("u_approver_needs_updated", false);
}
}
Yeah sure