"Confirm" box in client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 05:46 PM - edited 06-12-2024 05:46 PM
Hello Devs,
I want to show a confirm box when a field value is changed on the form. and When clicked 'ok' on confirmation box, I need to hide the pending reason field. I am using below script. and I see confirm box is populated every time the form is loaded. and if I use "if (isLoading || newValue === '')" in the first line, the pending reason field is never hidden.
what is wrong in the above script?
Thanks in advance.
Rocky.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 05:56 PM
Hi @Rocky5
Can you change the script in the below format
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue == '-5') {
g_form.setDisplay('pending_reason', true);
g_form.setMandatory('pending_reason', true);
} else {
var answer = confirm('PR will be removed');
if (answer) {
g_form.clearValue('pending_reason');
g_form.setMandatory('pending_reason', false);
g_form.setDisplay('pending_reason', false);
} else {
// add the functionality you needed
}
}
}
Thanks and regards
Sai Venkatesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 06:47 PM - edited 06-12-2024 06:50 PM
Hi @SAI VENKATESH ,
I tried that no luck. I still see confirm box every time the form loads. Like said earlier if I use this line below line, the pending reason is never hiding.
if (isLoading || newValue === '') {
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 11:13 PM
Hi @Rocky5 ,
Can you please try this:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue == '-5') {
g_form.setDisplay('pending_reason', true);
g_form.setMandatory('pending_reason', true);
}
else {
var answer = confirm('PR will be removed');
if (answer) {
g_form.clearValue('pending_reason');
g_form.setMandatory('pending_reason', false);
g_form.setDisplay('pending_reason', false);
} else {
return false;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 04:58 AM