return false; not working in on change Client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 10:54 AM
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (g_scratchpad.x == '5 year') {
var answer = confirm(" are you sure to change long term holding ");
if (answer == true) {
g_form.addInfoMessage("long term holding changes to " + newValue);
} else {
return false;
}
}
}
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 10:58 AM
Hi,
I do not think return false will work in an On Change client script.
This works in an On Submit client script where return false is used to abort form submission.
What here you need to do is in Else part, clear out the field value and make it mandatory so that user will not be allowed to proceed with form submission.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (g_scratchpad.x == '5 year') {
var answer = confirm(" are you sure to change long term holding ");
if (answer == true) {
g_form.addInfoMessage("long term holding changes to " + newValue);
} else {
g_form.clearValue('Field Name');
g_form.setMandatory('Field Name',true);
}
}
}
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 11:17 AM
once user hit cancel for confirm , value should return to '5 year';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 11:22 AM
Then update your script as below:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (g_scratchpad.x == '5 year') {
var answer = confirm(" are you sure to change long term holding ");
if (answer == true) {
g_form.addInfoMessage("long term holding changes to " + newValue);
} else {
g_form.setValue('Field Name',oldValue);
}
}
}
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2022 09:49 AM
hi shloke04,
out of town ,sorry for late reply
same problem, in confirm box, if cancel is clicked, then again confirm box came and doesn't vanish until i click ok. although value is not changed but need to fix it.