Placing redirect in to OnAfterUpdate

I needed to redirect the user after form has been submitted, so logical way to get that done was to add sc_redir(""); in to OnAfterUpdate action.
This does work however redirection happens before form changes are saved, despite being in an action that should happen after update took place.

This looks broken to me, as I expect OnAfterUpdate to execute after record has been updated in the database.

At the moment my solution has been to use ajax to update the form and bypass built in update button altogether.

Hi Proper,

Usually I do sc_redir() in the onValidateSuccess.
This code is executed after the OK button is hit and after a onValidate is executed without errors.

Sometimes you’ll need to use: sc_commit_trans(“Connection”).
The documentation tells you: [HR][/HR]
In form applications, there are events that perform transactions with the database (Ex: onAfterInsert, onAfterUpdate, onAfterDelete, onBeforeInsert, onBeforeUpdate, onBeforeDelete, etc…).
The transactions control of these events is done by Scriptcase itself, if the connection provided is the same of the application.
However, if the user has to perform any type of redirection in these events, it is necessary to use the macro sc_commit_trans before the redirect to secure the transactions previously performed.

Ex: onAfterUpdate - Using redirection after update a record:
sc_commit_trans(); sc_redir(‘grid_main’); [HR][/HR]
I hope this will help.

Sincerely
Gunter Eibl

1 Like