When user click on 'Cancel' then changed value should stay with old value, but sth is not working

Kasia5
Tera Contributor

Hi All

 

I've created the pop up message by client script like below:

Kasia5_0-1706018936930.png

so when task is assigned to specific group and uset wants to change it then he can see the confirm pop up message:

,,If you change the assignment group, the XYZ cannot be longer properly synchronized with ABC"

and two buttons 'OK' and 'Cancel'

 

Currentlt when I change the group I see the pop up and when I click on 'Cancel' the value stay as changed,,

I want to achieve to revert this value to the old one when I click on 'Cancel'

Example:

Task assigned to group 123

I change it to 456

I see the pop up

I click 'Cancel'

The task is again assigned to group 123

 

What should I add to the script?

function onChange(control, oldValue, newValue, isLoading) {

    var groupName = g_form.getValue('assignment_group');

    if (groupName != '5f03388b1b4d9850ab5810229b4bcbbf') { //group is SIAM SP ASEU NSSR Managersif (vAnswer) 

        confirm('If you change the assignment group, the XYZ cannot be longer properly synchronized with ABC');
        
    }
}
2 REPLIES 2

SunilKumar_P
Giga Sage

Hi @Kasia5, Can you try the below script?

function onChange(control, oldValue, newValue, isLoading) {

    var groupName = g_form.getValue('assignment_group');

    if (groupName != '5f03388b1b4d9850ab5810229b4bcbbf') { //group is SIAM SP ASEU NSSR Managersif (vAnswer) 

        if (confirm('If you change the assignment group, the XYZ cannot be longer properly synchronized with ABC')) {
            g_form.save();
        } else {
            g_form.setValue('assignment_group', oldValue);
        }

    }
}

 

Regards,

Sunil

 

Robbie
Kilo Patron
Kilo Patron

Hi @Kasia5,

 

Please see the below tweak to your script ready for you to copy and paste.

Please note, you don't want to save the form as highlighted in other posts.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Thanks, Robbie

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

var groupName = g_form.getValue('assignment_group');
 
if (groupName != '5f03388b1b4d9850ab5810229b4bcbbf') {
var answer = confirm('If you change the assignment group, the XYZ cannot be longer properly synchronized with ABC');
if (answer != true) {
g_form.setValue('assignment_group', oldValue);
}

}
}