How to Redirect to the previous page after deletion of a record.

zakir5
Kilo Contributor

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.')

11 REPLIES 11

Sukraj Raikhraj
Kilo Sage

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

Allen Andreas
Administrator
Administrator

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!

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.

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!