How to Return to Prior Page, Display Dynamic Title after Object Deleted

I’ve got an app where the title is dynamic on pages based on what you’ve clicked. You’re in a “League” it shows the “League Name” as the title. If you click into a “Team” from there, it shows the “Team Name”. The problem arises when I click into a team and then click the “Delete Team” button. When the team is deleted, I want to take the user back to the League they were in, but I can’t send the Team’s League because the team has been deleted. Any idea the correct way to get back to that original league page (or somehow pass that league’s info back to that page) before the team was deleted?

You can put a “isDeleted” yes/no field on Team, then when the user deletes it all they really do is set that field to “Yes”, which then still allows you to point to the Team’s League and return to the page.

This also helps with when they hit delete all the data on page doesn’t suddenly blank out while they are being redirected

This would require some more work like if you have any RGs searching for Teams, now you will need to add that constraint that it’s not deleted.

1 Like

Or probably easier to do:

Have a custom state on page, type League, then on page load (or on delete button click) you set the state to the League. Then it is stored there available to you to redirect.

Gotcha so a soft delete. I assume I’ll need to rewrite things to filter that data out when calling it. Would you ever run anything to clear out those records eventually?

I’ll have to look into the second option, I’ve never done anything with custom states yet.

Thanks for the idea.

2nd options is easier just to get working right away without adding any new constraints, downside is you actually are deleting stuff, maybe you want a soft delete for historical purposes? Then later they can have an undo button and stuff :+1:

I went with the soft delete option and then am using constraints when displaying information to exclude isDeleted = yes. If you have some ideas on best practices on handling that let me know, but for now you helped solve my initial problem with the soft delete idea. Thanks!

1 Like