Double Confirmation Should come when i select status field as reject?

Kruthik M Shiva
Tera Contributor

Hi All,
I have a requirement to pop up confirm if you have to reject the form and two choices should be there in pop up as yes or no if they select as change to reject status else previous status only be set. Please do share what needs to be done for this and if any scripting required please help on that as well.
Thanks in advance.

1 ACCEPTED SOLUTION

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Kruthik M Shiva ,

 

Kindly refer below code to achieve your requirement.

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

    if(newValue == 'rejected'){ // please use proper backend name of the reject status

	var answer = confirm('Do you wish to proceed with Rejecting the change');

	if(!answer){
		return false;// this will not allow the user to save the form with reject status
	}

	}

}

 

Please mark my answer helpful & accepted if it helps you resolve your issue.

 

Thanks,

Danish

View solution in original post

17 REPLIES 17

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Kruthik M Shiva ,

 

Kindly refer below code to achieve your requirement.

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

    if(newValue == 'rejected'){ // please use proper backend name of the reject status

	var answer = confirm('Do you wish to proceed with Rejecting the change');

	if(!answer){
		return false;// this will not allow the user to save the form with reject status
	}

	}

}

 

Please mark my answer helpful & accepted if it helps you resolve your issue.

 

Thanks,

Danish

Hi @Danish Bhairag2 
I want the pop up to come as soon as change status that is before saving the form once they change the status to reject that time only that pop up should appear. Can you please tell for that? will it work once user changes the status field before saving form?

Hello @Kruthik M Shiva ,

The above mentioned code works as you expected, confirm() metho in onChange client script popup when you change the status value, If you click yes, then the answer variable will be true, if you click no, then the answer variable will be false. 

You can implement your code in

if(!answer){

}

block

 

 

Please mark my answer helpful  & correct if it helps you
Thank you

G Ramana Murthy
ServiceNow Developer

Hi @RAMANA MURTHY G 
It was working but when confirm thing if we cancel still its selected as reject value but it should set to old value right if i select as cancel. can you please what needs to be done for that?