how to add a pop up option for a check box in incident form and stay the field checked when it is ok

raj765_32
Tera Contributor

hi can anyone help me with scenario for :

 

i want to add a pop up message with a conformation for the field' consider for knowledge' check box field in incident form, when ever it is of for conformation stay the field value checked, when it is cancel remove the check option.

here is my requirment:

 

"Add a pop-up question "Are you sure?" appear when a user checks the "Consider for Knowledge "box on the Resolution tab of an incident. Have the checkmark stay checked if ok/yes."

 

code:

 

 
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var value = g_form.getValue('knowledge');
if (value == true) {

var answer = confirm('Are You Sure?');
if (answer == true) {
g_form.setValue('knowledge', true);

}
else{
g_form.setValue('knowldege',false);
}
}



}
1 ACCEPTED SOLUTION

SN_Learn
Kilo Patron
Kilo Patron

Hi @raj765_32 ,

 

Please try the below onChange client script:

 

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);
        }
    }
}

 

 

Mark this as Helpful / Accept the Solution if this helps

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

View solution in original post

4 REPLIES 4

SN_Learn
Kilo Patron
Kilo Patron

Hi @raj765_32 ,

 

Please try the below onChange client script:

 

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);
        }
    }
}

 

 

Mark this as Helpful / Accept the Solution if this helps

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

hi this code is making the box unchecked again when we save the form. after i click on ok

Hi @raj765_32 ,

 

I have tested it in PDI and it is working fine. Have a look at the screenshots:

 

1. Clicked on the Checkbox, the pop up appeared:

 

SN_Learn_0-1720453164112.png

 

2. Clicked Ok and saved the form:

SN_Learn_1-1720453220954.png

 

 

The client script:

SN_Learn_2-1720453347173.png

 

Please check if there are any script running on the same field, you need to deactivate them.

 

Mark this as Helpful / Accept the Solution if this helps

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

SidharthReddy
Tera Contributor

@raj765_32 

 

Please use the below code .

SidharthReddy_0-1719379914308.png

 

SidharthReddy_1-1719379925898.png