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 

then add this code of dialog window in that "Close" ui action

if it's server side then make it combination of client+server

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
Tera Guru

Hello Ankur and SUmanth,

 

IS there a way to do this from Business rule?

Because we have Save button on the Change form and as well as Close button,

 

So, can we create a BR, When to Run: State changes to Closed

 

like this..

 

 

Regards,

Lucky

@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

@Lucky1 

this worked for me

Ensure you add the closure details before closing the CHG

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() {
        g_form.setValue("state", "3");
        gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_closed");
    }
    function doCancel() {
        return false;
    }
}

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

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

Output:

close button.gif

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 

Hope you are doing good.

Did my reply answer your question?

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