Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Using UI Action button to refresh Page

abhijee
Tera Contributor

Hello,

I have created a UI Action Button on a LIST that deletes an incident. After the incident is deleted, I want the page to auto-refresh. The code I've written is working as expected, and it successfully refreshes the page. However, after the refresh, the deleted incident record still appears in the list view. When I manually refresh the page, the deleted record is not shown.

Thank You.

 

 

function demo()

{
var gm = new GlideModal("glide_confirm_basic", true, 600);
gm.setTitle("Confirmation");
gm.setPreference("title", "Are you sure you want to delete all closed events?");
gm.setPreference("onPromptComplete", function() {
// Inside this function, you should specify the sys_id(s) of the incident(s) you want to delete.
var sys_id_to_delete = '3c70ca6697bc3110df62b3b6f053af59';
var gr = new GlideRecord('incident');
gr.addQuery('sys_id', sys_id_to_delete);
gr.query();

if (gr.next()) {
gr.deleteRecord();
alert("Incident deleted successfully.");

// Reload the page after deleting the incident
// window.location.reload(true);

// window.location.href = "https://dev140375.service-now.com/now/nav/ui/classic/params/target/incident_list.do";
action.setRedirectURL(current);

} else {
alert("Incident not found or could not be deleted.");
}
});
gm.setPreference("onPromptCancel", function() {
alert("You clicked on 'Cancel'");
});
gm.render();
}

0 REPLIES 0