Onload client script button not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-08-2026 03:39 AM - edited ā10-08-2026 03:41 AM
Hi,
In the below onload client script, I kept the button "clear flag" when we click on this button it should make the checkbox field u_cirt_in_progress to false and should save the form and stay on the same page but right now it is taking me to the new record page after clicking and it is not setting the checkbox field u_cirt_in_progress to false. Could you please provide the fix for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-08-2026 03:48 AM
Hello @krishnanara
Youāre missing closing quote
g_form.setValue('u_cirt_in_progress', 'false');
Correct html button syntax
<button type="button" onclick="clearflag(); return false;">Clear Flag</button>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-08-2026 04:29 AM
it is still taking me to the new record page and not setting the checkbox field u_cirt_in_progress to false
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-08-2026 05:13 AM
Hello @krishnanara
Please uncheck Isolate Script
function onLoad() {
if (g_form.getValue('u_cirt_in_progress') == 'true') {
g_form.addErrorMessage('ā This account in progress ' + '<button type="button" onclick="clearflag(); return false;">Clear Flag</button>');
}
}
function clearflag() {
g_form.setValue('u_cirt_in_progress', 'false');
g_form.save();
return false;
}
Validation Results:
Existing Saved Record as True:
Clear Flag clicked:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-08-2026 03:50 AM
not good practice to use g_form.save() in onLoad client script
there is issue in your syntax
try this
function onLoad() {
if (g_form.getValue('u_cirt_in_progress') == 'true') {
g_form.addErrorMessage(
'ā This account in progress ' +
'<button type="button" onclick="clearflag()">Clear Flag</button>'
);
}
}
function clearflag() {
// Set checkbox to false
g_form.setValue('u_cirt_in_progress', 'false');
// Save the record and stay on the same form
g_form.save();
// Prevent any default link/button behavior
return false;
}
š” If my response helped, please mark it as correct ā and close the thread šā this helps future readers find the solution faster! š