I have a form which has the following sequences -
- onValidate with some validations
- onBeforeInsert to generate an unique ID using postgres’ sc_lookup(rs, “SELECT gen_random_uuid()”);
- in onBeforeInsert after step (2) above, i store the generated ID into global variable
- in onAfterInsert, I have to send a verification email to the newly registered user in a form. This requires to retrieve the newly stored email for the user with a generated ID. (Note I do not want to use the email from the form field input, but from the one freshly stored in db)
- I use sc_lookup to get the new user details
- BUT not only this fails, it even breaks the insert of the new record. If I comment out the sc_lookup , then the insert is successful and I am able to see the newly inserted record’s global variable also in onAfterInsert with an echo command
Scriptcase + Postgres with pg generated ID using random id gen.
Solution : used sc_commit_trans before the sc_lookup in the onAfterInsert
QUESTION: Should not sc_commit_trans occur with the form’s insert ?