How to create a confirmation box that changes the state of a form

kartikey
Tera Contributor

Hi Everyone, 

i wish to create a confirmation box on submission of a form that asks if you wish to change the state of the parent case to work in progress.
it should simply ask 'do you want to resume the case' with two options yes or no, if i select yes the parent case of that form should change it's state to work in progress, and if i select no then  nothing should happen and it should simply submit the form.
Does anyone know how do i achieve this?

Thanks,
kartikey

6 REPLIES 6

Sujatha V M
Kilo Patron
Kilo Patron

@kartikey Please refer the below link for reference only: 

 

Kindly change according to your requirement. 

 

https://www.servicenow.com/community/developer-articles/ui-action-add-confirm-window-on-the-click-of...

 

Please mark this as helpful and accept it as a solution if this resolves your query.

Thanks,

Sujatha V.M.

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.

Can this be achieved without a UI action?

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @kartikey ,

 

Create a UI action with glideModel api , use the below code logic to build your code for this requirement.

function confirmDialog(){
	var gm = new GlideModal('confirm');
	//Sets the dialog title
	gm.setTitle('Confirmation'); 
	//Set up valid custom HTML to be displayed
	gm.renderWithContent('\
            <div style="padding:15px"><p>Confirm?</p>\
                <div style="padding:5px;float:right">\
                    <button style="padding:5px;margin-right:10px" \
                        onclick="window.takeAction(this.innerHTML)" \
                        class="btn btn-default">No</button>\
                    <button style="padding:5px" \
                        onclick="window.takeAction(this.innerHTML)" \
                        class="btn btn-primary">Yes</button>\
                </div> \
            </div>'); 

	//We'll use the windows object to ensure our code is accessible from the modal dialog
	window.takeAction = function(thisButton){
 
		//Close the glide modal dialog window when either button is pressed.
		gm.destroy();

		//perform the appropriate action on the client.
		if(thisButton=='Yes'){
			alert("You pressed 'Yes'");
		} else if(thisButton=='No') {
            alert("You pressed 'No'");
        }
	};
	return false;//prevents the form from submitting when the dialog first loads
}

 

Ref : Click here 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hi, can this be done without a UI action?