While clicking the button a confirmation alert box should be displayed with text the form is being submitted with 2 options yes and no

Community Alums
Not applicable

While clicking the button a confirmation alert box should be displayed with text "the form is being submitted" with 2 options yes and no. when yes is selected form should be submitted and when no is selected it should not be submitted and should remain in the same page. Can anyone help me with this functionality.

1 ACCEPTED SOLUTION

Imran Ahmad1
Kilo Guru

Hii @Maradani Revathi 

 

In the UI Action change the server side code as per your requirement

Also attached the screen short below that will help you more

Here is the code for confirmation alert:-

function UpdatePdemo(){
	var answer = confirm("are you sure wants to update the priority to 1-cretical");
	if(answer == true){
		gsftSubmit(null,g_form.getFormElement(),'sys_update_value');
	}else{
		return false;
	}
}
if(typeof window == 'undefined')
	priorityUpdate();

function priorityUpdate(){
	current.impact = '1';
	current.urgency = '1';
	current.update();
	action.setRedirectURL(current);
}

find_real_file.png

 

find_real_file.png

 

 

 

Regards,

Imran Ahmad

 

Please mark the response as Helpful/Correct, if applicable. Thanks!

View solution in original post

8 REPLIES 8

Community Alums
Not applicable

Hi Ankur,

 

Can you please explain about Confirm javascript prompt in detail

 

Thanks!

Please share your existing script

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Imran Ahmad1
Kilo Guru

Hii @Maradani Revathi 

 

In the UI Action change the server side code as per your requirement

Also attached the screen short below that will help you more

Here is the code for confirmation alert:-

function UpdatePdemo(){
	var answer = confirm("are you sure wants to update the priority to 1-cretical");
	if(answer == true){
		gsftSubmit(null,g_form.getFormElement(),'sys_update_value');
	}else{
		return false;
	}
}
if(typeof window == 'undefined')
	priorityUpdate();

function priorityUpdate(){
	current.impact = '1';
	current.urgency = '1';
	current.update();
	action.setRedirectURL(current);
}

find_real_file.png

 

find_real_file.png

 

 

 

Regards,

Imran Ahmad

 

Please mark the response as Helpful/Correct, if applicable. Thanks!

can you please explain the "

gsftSubmit(null,g_form.getFormElement(),'sys_update_value');

" Specifically the last part??

I am attempting to repurpose this to provide a prompt/confirmation before another function as youll see in the script below. The goal is to have the user confirm the state change before it happens. I would appreciate any help you could provide.

 

function KMMScancel(){
var answer = confirm("Are you sure you would like to CANCEL this KMMS record?");
if(answer == true){
gsftSubmit(null,g_form.getFormElement(),'sys_update_value');
}else{
return false;
}
 
}
(function executeRule(current, previous /*null when async*/) {
 
// Add your code her
current.state = 4;
current.setWorkflow(false);
current.update();
 
})(current, previous);