How to Redirect to the previous page after deletion of a record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2021 08:00 AM
Hi guys, I used the below code to Redirect to previous page on my custom delete button on a related list . so that after deletion of record it should redirect to the previous page. But as of now, it is not working. Please suggest the correct syntax to redirect to the previous page (not the hard corded URL).
action.setRedirectURL(previous);
gs.addInfoMessage('The current request has been deleted.')

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2021 08:07 AM
Is this on a UI action?
that's because it might be taking the previous url which user has visited; why not form the url itself in the processing script and redirect to that; you already know from where the UI page is called
https://community.servicenow.com/community?id=community_question&sys_id=0e5a00a8db19678067a72926ca9619d7

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2021 08:09 AM
Hi,
You may want to consider redirecting them back to the list of records as is common-place when a record is deleted. You can use script such as:
var url=current.getTableName()+'_list.do';
action.setRedirectURL(url);
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2021 09:25 PM
Hi Allen, Thanks for your response. but i want after deletion of related list record it redirect to the main form through which the related list added.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2021 06:43 AM
Hi,
Please use the code I've provided to adjust where you want them to go. My reply is an example, but use case would be that you redirect to list view, but you can change the page accordingly in the url line.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!