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  

UI action for cancel flow

AnandKumar1
Tera Expert

Hi All.

When i initiate the Cancel Renewal UI action. I need to bring the info message that, instead of cancelling the renewal do you need to revoke the certificate. If yes, then it should redirect to a catalog which i use. if user click the info message cancel then it should cancel the renewal.

function CheckConfirm() {
    var answer = confirm("Do you want to revoke the certificate? if Yes click Ok. To proceed cancelling the certificate click cancel");

    if (answer != true) {
        alert("answer not true");
        gsftSubmit(null, g_form.getFormElement(), 'cancel_renewal'); 
    } else {
    alert("serviceportal end point");
    }
}
if (typeof window == 'undefined') {
    current.state = 4; /// CAncel the record\
    current.work_notes = "The certificate has been set to cancelled.";
    current.update();
    action.setRedirectURL(current);
    gs.addInfoMessage('cancelled.');
}

 

 

My else condition is not redirecting to the catalog url. However, i checked the alert is working. Am i missing any syntax here?

 

Thanks.

6 REPLIES 6

Aniket Chavan
Tera Sage
Tera Sage

Hello @AnandKumar1 ,

Please give a try to the code below and see how it works for you.

function CheckConfirm() {
    var answer = confirm("Do you want to revoke the certificate? If Yes, click OK. To proceed with cancelling the certificate, click Cancel");

    if (answer != true) {
        alert("Answer not true");
        gsftSubmit(null, g_form.getFormElement(), 'cancel_renewal'); 
    } else {
        alert("Service portal endpoint");
        window.open("https://test.service-now.com/sp?id=sc_cat_item&sys_id=293403d22b52e100e587593069da1575", "_self");
    }
}

if (typeof window == 'undefined') {
    current.state = 4; // Cancel the record
    current.work_notes = "The certificate has been set to cancelled.";
    current.update();
    action.setRedirectURL(current);
    gs.addInfoMessage('Cancelled.');
}

 

Let me know your views on this and Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket

 

Hi Aniket,

Thanks for your eamil. I am getting same response. I can see the alert. But it's not redirecting to Service portal.

Service portal endpoint

Hello @AnandKumar1 ,

Oh okay then lets try with this below approach.

function CheckConfirm() {
    var answer = confirm("Do you want to revoke the certificate? If Yes, click OK. To proceed with cancelling the certificate, click Cancel");

    if (answer != true) {
        alert("Answer not true");
        gsftSubmit(null, g_form.getFormElement(), 'cancel_renewal'); 
    } else {
        alert("Service portal endpoint");
        window.location.href = "https://test.service-now.com/sp?id=sc_cat_item&sys_id=293403d22b52e100e587593069da1575";
    }
}

if (typeof window == 'undefined') {
    current.state = 4; // Cancel the record
    current.work_notes = "The certificate has been set to cancelled.";
    current.update();
    action.setRedirectURL(current);
    gs.addInfoMessage('Cancelled.');
}

Hi Aniket,

I am getting alert and resulting same. I have tried earlier once with "window.location.href" as well :(.