Gaelle Fernandez

sugar 7 : Leads, after_save logic hook and redirection

Discussion created by Gaelle Fernandez on Jul 21, 2014
Latest reply on Sep 5, 2016 by Rolustech Support
Hello SugarLovers!

i am customizing Leads module on 7.2.0 Pro.

I have created an after_save logic hook, which looks if the record is converted ($bean->converted = '1'). If yes, my hook does delete the record. It works well.

But after the record is saved, Sugar point on the recordview of the record, and because i've deleted it, i have a 404 error (which is totally logic and normal).

I would like after the deletion, to redirect to the listview page.

How can i do that, ONLY in the hook? (no js overriding, please)

I've already read this topic :
which lead me to this one :
redirect after delete - Sugar 7

and well, Mike found a way to override the delete function. But i'm quite sure the leads will be deletable through other ways than converting, and i don't want to throw js message...

So do you have any idea on how i could achieve that?
Maybe @eggsurplus has a right beginning of clue with
Can you set the return_module, return_action, and return_id in the logic hook? If not, there must be somewhere up the chain that you can so that the router will use your preferred route.

even if i don't know what it could do

maybe use another sort of hook?
Thanks a lot for helping me on this.