UI action for cancel flow
						
					
					
				
			
		
	
			
	
	
	
	
	
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
01-31-2024 04:28 AM
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.
My else condition is not redirecting to the catalog url. However, i checked the alert is working. Am i missing any syntax here?
Thanks.
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
01-31-2024 06:47 AM
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
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
01-31-2024 06:56 AM
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
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
01-31-2024 07:00 AM
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.');
}
					
				
			
			
				
			
			
				
			
			
			
			
			
			
		- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
01-31-2024 07:11 AM
Hi Aniket,
I am getting alert and resulting same. I have tried earlier once with "window.location.href" as well :(.
