How to keep Yes or No, instead of Ok and Cancel in the Confirm alert

Lucky1
Tera Guru

Hello all,

 

On the Incident form, when the user is trying to save the form after the state has been moved to Resolved, then I need to display an alert with Yes or No, instead of Ok and Cancel using confirm("Validated with user?");

So, can someone let me know how can we do this?

 

 

Regards,

Lucky

1 ACCEPTED SOLUTION

@Lucky1 

business rule can't show you dialog box as dialog box only works from client side code

I suggested to use that dialog box code in the Close button

Did you try that approach?

Don't create any client script

function moveToClosed() {

    var dialog = new GlideModal('glide_modal_confirm', true, 300);
    dialog.setTitle('Confirmation');
    dialog.setPreference('body', 'Validated with user?');
    dialog.setPreference('focusTrap', true);
    dialog.setPreference('onPromptComplete', doComplete);
    dialog.setPreference('onPromptCancel', doCancel);
    dialog.render();

    function doComplete() {
        callback(true);
        g_form.setValue("state", "3");
        gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_closed");
    }

    function doCancel() {
        callback(false);
        return false;
    }
}

if (typeof window == 'undefined')
    setRedirect();

function setRedirect() {
    current.update();
    action.setRedirectURL(current);
}

AnkurBawiskar_0-1747129226310.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

19 REPLIES 19

@Lucky1 

We cannot do that from business rule. You can do it in UI Action for "Close" button instead.

You can use the code suggested by @Ankur Bawiskar for that.

Feel free to reach out for any further help.

 

Regards,

Sumanth

Hello SUmanth and Ankur,

 

Yes, I can go ahead with updating "Close" UI action. But here we have an existing scenario also, like after selecting Close code as successful in Implement state and right cick on the form and save it, then it will go to close state.

 

So, here as we write the logic in "CLose" UI action, it will fail here right?

 

SO, I am not understanding how to convince all the times

 

 

Regards,

Lucky

@Lucky1 

then you can use onSubmit for that case and show the pop-up. check in onSubmit what's the state? if it's close then show popup

this covers your above case where they select close code and right click -> save

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@Lucky1

Along with UI action script, you can write an onSubmit client script and use the glideDialogClass code which we shared in earlier replies. 

Hello Sumanth,

 

How can I write the on Submit CS once the Change request is closed from the workflow?

Can you please provide me the code?

 

Also, I have used Confirm ("Are you Sure?"); in on Change client script, and inside the logic,

if(newValue == '3') //3 is closed{

alert("New value is "+newValue);

confirm("Are you sure you want to close?");

}

 

but here, the alert message itself is not coming and the CR is getting closed as it follows the workflow.

 

Regards,

Lucky