How to Redirect After Record Deletion in Service Portal UI Action

SHWA
Tera Contributor

Hello,

 

I am working on implementing a UI Action in a Service Portal form screen that is supposed to delete a record. I am using current.deleteRecord(); for the deletion process, and it successfully removes the record. However, I am facing an issue where the screen does not redirect after the record is deleted. Instead, it remains on the now-empty form screen.

How can I implement a redirect to the previous page or a different specified page after the record deletion? Any guidance or code snippets that could help resolve this would be greatly appreciated.

 

Thank you in advance for your help!

4 REPLIES 4

SK Chand Basha
Tera Sage

Hi @SHWA 

Here you want's to include this

action.setRedirectURL(url);

Mark it Helpful and Accept Solution!! If this helps you to understand .

Hello @SK Chand Basha
Thank you for your suggestion to use "action.setRedirectURL(url);".
However, I tried implementing it within the Service Portal's server-side script, and it seems that this method does not function as expected in this context.
It appears that
setRedirectURL is typically used in server-side scripts for Platform UI forms and not within Service Portal widgets.
If there are any alternative approaches or further insights you could share for redirecting within Service Portal server scripts, it would be greatly appreciated. Thank you once again for your help!

Hi @SHWA 

  1. Can you check this  video for redirection

 

https://youtu.be/ODc5q6X8KY4?si=FRwiB5kSgpNuQk8n

 

Mark it Helpful and Accept Solution!! If this helps you to understand. 

Maddysunil
Kilo Sage

@SHWA 

I think in Service Portal, you can achieve redirection after record deletion using  window.location.href property to redirect the user to a specified URL after the record deletion is successful.

Here's how you can implement this in your UI Action:

 

 

function deleteRecordAndRedirect() {
    var gr = new GlideRecord('your_table_name');
    if (gr.get(current.sys_id)) {
        gr.deleteRecord();
        // Redirect to a specified URL after record deletion
        window.location.href = 'https://your_service_portal_page_url';
    }
}

 

 

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

 

Thanks