how to pop up alert message and save the box checked when the form saves
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 08:24 AM
hi can anyone help me with the code that i have written a code to display an message when the check box is checked and when clicked on ok let the check box checked and when clicked on cancel then uncheck the check box
what happens is that after i click on 'ok' and save the form the check box is getting unchecked:
here is the code:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 08:34 AM
Hi @raj765_32 Try below code
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (g_form.getValue('knowledge') === 'true') {
var answer = confirm('Are you sure you want to set this to true?');
if (!answer) {
g_form.setValue('knowledge', false);
}
}
}
Regards,
Sid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 02:41 PM
Hi @raj765_32 ,
The issue in your code is while setting the knowledge field you are setting it to true. which is not correct.
As Sid mentioned the code should work fine.
One correction to the code that we should consider is that while setting the value for setValue function please consider putting a string value as some other type can cause issue. See the below
Here is an updated code-
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (g_form.getValue('knowledge') === 'true') {
var answer = confirm('Are You Sure?');
if (!answer) {
g_form.setValue('knowledge', 'false');
}
}
}
If my response has resolved your query, please consider giving it a thumbs up and marking it as the correct answer!
Thanks & Regards,
Sanjay Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2024 06:08 AM
Hey @raj765_32
Make sure the type of the field will be correct as your script and try to apply the script