[SOLVED] sc_redir() in AfterUpdate - record doesn't update

If you put an sc_redir() into the AfterUpdate event of a form, then the form doesn’t actually update. It’s like it does the sc_redir() before the update happens.

I am in an app called form_person. In the AfterUpdate event, I put

 sc_redir(form_person)   // Reload form after update

Now, if I edit one or more of the fields and click Save, the form reloads, but it doesn’t save my changes.

Please can you check this out and advise.

Thanks

Jeff

I think you must use sc_commit_trans(); before you use sc_redir.

I think you must use sc_commit_trans(); before you use sc_redir.

exactly!

http://www.scriptcase.net/docs/en_us/v9/manual/14-macros/01-general-view/#sc_commit_trans

If the user, in any of these events, use an application redirectioning (macro “sc_redir”) must before the redirect, use this macro to guarantee the transactions previously effected.

Thanks Alvagar, and Yuri. I thought because it was after the update, the commit would already have happened. So I’ve learned something very useful. :smiley:

This is also happened to me, and i didn’t know why…
Then i use the

sc_commit_trans();
sc_redir(‘MyApplication’);

and everything worked correctly
Thank you

1 Like

Transactions are commited automatically when the event AfterUpdate completes.
If not commited the transaction is rolled back.
By putting sc_redir in the AfterUpdate event you are changing the standard flow of execution, preventing the event to complete and bypassing the automatic commit.
You need to add sc_commit before sc_redir in AfterUpdate to commit the transaction.