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

HI @Kruthik M Shiva ,

For that you need to write else block as

if(!answer){
    // your block
}
else{
       g_form.setValue('status',oldValue);
}

 

Please mark my answer correct and helpful, if it helps you

Thank you

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

G Ramana Murthy
ServiceNow Developer

Hi @Kruthik M Shiva ,

 

U need to add that code in On change script where variable you will select as status.

So whenever some1 changes the status to reject the onChange script will execute.

 

Mark my answer helpful & accepted if it helps you resolve your query.

 

Thanks,

Danish

Hi @Danish Bhairag2 ,
But when the confirm pop up comes if i select as cancel as well i can see status as reject in form but if i select as cancel it should ideally set whatever the previous status right if we click ok then only it should be set as new value

Hi @Kruthik M Shiva ,

 

Please add 1 line in below code

if(!answer){

g_form.setValue('status',oldValue);

}

 

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

 

Thanks,

Danish

Hi @RAMANA MURTHY G  , @Danish Bhairag2 ,

Is there anyway i can remove the title please do let me know and how to remove it.
PFB screenshot for reference.
Thanks