Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Pop up confirmation on state change, not using a UI Action

heathers_
Kilo Sage

We have a requirement to add a pop-up confirmation message when saving a change task to complete. We are not using an UI Action button for the close task but instead saving from the state field choice list. I was able to accomplish the alert pop-up through a client script but I need them to be able to select 'Yes' or 'No'. If no is selected, then the change task will not save. Thanks in advance for your assistance.

1 ACCEPTED SOLUTION

heathers_
Kilo Sage

Thank you all. I was also able to accomplish my desired results with this onSubmit client script.

 

function onSubmit() {
	
	var state = g_form.getValue('state');
	
	if((state == 3) || (state == 4) || (state == 7)){
		return confirm('Are you sure you want to close this task?');
	}
	
	if(state == 6){
		return confirm('Are you sure you want to cancel this task?');
	}
	
}

View solution in original post

5 REPLIES 5

Ahmmed Ali
Giga Sage
Giga Sage

create one onSubmit client script:

var val = g_form.getValue("state");

if (val== '4') // verify state value for close.
{
var answer=confirm("Are you sure you want to Close the task?");

return answer;
}

Thanks,

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Rick Marsha
Giga Expert

Hi heathers,

A bit more complex than browser prompts, but here's a GlideModal dialog I've used for a client-side UI action that should work in a client script with minor adjustment:

// *** F U N C T I O N  showConfirmDialog ( ) *********************
//
// Yes / No prompt to comfirm before primary function
//
function showConfirmDialog() {
	var subCallback = function() {
		submitItAlready();
	};
	
	// set up the dialog
	var dialogContent  = 'Are you ready to send this request to the client?';
	var subDialogClass = typeof GlideModal != 'undefined' ? GlideModal : GlideDialogWindow;
	var subDialog      = new subDialogClass('glide_confirm_standard');
	subDialog.setTitle('Submit for approval');
	subDialog.setPreference('warning', true);
	subDialog.setPreference('title', dialogContent);
	subDialog.setPreference('onPromptComplete', subCallback.bind(this));
	subDialog.render();
	
}

// *** F U N C T I O N  submitItAlready ( ) *********************
//
// Callback for the confirmation dialog
//
function submitItAlready() {
	// submit the form
	gsftSubmit(null, g_form.getFormElement(), 'submit_approval');
	
}

find_real_file.png

 

Hi Mike,

Very nice alert message. So different than the normal browser prompt. I am trying to use your code in a OnSubmit client script however the alert message pops up briefly but disappears.

How can I get this alert message to stick until the user clicks either button?

heathers_
Kilo Sage

Thank you all. I was also able to accomplish my desired results with this onSubmit client script.

 

function onSubmit() {
	
	var state = g_form.getValue('state');
	
	if((state == 3) || (state == 4) || (state == 7)){
		return confirm('Are you sure you want to close this task?');
	}
	
	if(state == 6){
		return confirm('Are you sure you want to cancel this task?');
	}
	
}