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

Nikita30
Mega Sage

Hi Maradani,

 

Please create one onSubmit Client script and try the below code.

 

function onSubmit() {
//Type appropriate comment here, and begin script below

var msg = "The form is being submitted"

return confirm(msg);

 

}

 

 

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

 

Thanks,

Nikita

Community Alums
Not applicable

i need 2 options yes and no as well. can you please tell how can I achieve it

By using confirm dialog box code only You will get 2 options (OK ) and (Cancel)

 

var msg = "The form is being submitted"

return confirm(msg);

 

find_real_file.png

 

In case of OK form will be submit else it remain on same page.

 

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use Confirm javascript prompt which has OK and Cancel

For creating with Yes or No you would require UI page

Regards
Ankur

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