- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 05:44 AM
Hi All,
I have :
1) Display BR : Used to check whether current logged in user is a member of particular group or not. And it stores the value in scratchpad and send it to the client side.
2) OnChange CS : Based upon the scratch pad value, if it is true it allow the user to set priority as 1. If it is false, it will restrict the user to set priority value as 1 and displays an error message under the priority field.
At first time it is displaying the error message correctly. But again if i try to test the functionality I am getting this error
"Script error encountered when changing this field - please contact your System Administrator"
What could be the reason, how we can debug this..? Is it because of display BR?
Regards,
Sriraj
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 06:37 AM
I think it would be preferable to add a condition on the script to check oldvalue and newvalue, since as soon as you change impact using setValue() this onCHange script will again run.
You can validate by adding, if(oldValue != newValue)
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 05:49 AM
Hi Siraj,
Can you share the scripts once for BR & Client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 06:19 AM
Hi Jaspal, Thank you for the response.
This is the BR script :
(function executeRule(current, previous /*null when async*/ ) {
var checkGroup = gs.getProperty('priority.access.group');
g_scratchpad.grMember = gs.getUser().isMemberOf(checkGroup);
})(current, previous);
on-change client script : on impact field. (also written for urgency field)
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (g_form.getValue("impact") == 1 && g_form.getValue("urgency") == 1 &&!g_scratchpad.grMember) {
g_form.setValue("impact", oldValue);
g_form.showFieldMsg('priority','Test Message','error');
}
}
NOTE : I have tried deactivating the display BR and in the client script i have replaced g_userHasRole to check role instead of checking scratchpad variable. After doing this also i got that error.
Regards,
Sriraj

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 06:37 AM
I think it would be preferable to add a condition on the script to check oldvalue and newvalue, since as soon as you change impact using setValue() this onCHange script will again run.
You can validate by adding, if(oldValue != newValue)
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2022 08:35 PM
Thank you Aman
One last query, as per my script i am displaying the error message.
Test 1 : If condition satisfies, error message is displayed properly and stays on the screen.
Test 2 : Without loading the form I am re-testing again, that time also condition satisfies but error message comes for a second and hided from the form.
Test 3 : Without loading the form I am re-testing again, error message stays on the screen.
So on & off, error message is getting hided what could be the reason?