Possible Reason
Well, just see the sequence of function calls when inserting a record:
- UI: You click #insert button
- Browser POSTs data to server
- AppGini code executes
before_insert()
-hook
- AppGini code inserts the record into the database
- AppGini code calls
after_insert()
-hook
(here you echo "<script>alert('$message');</script>";
- AppGini reloads the Detail View (or redirects to a different page, if configured)
Due to the immediate reload of Detail View (showing inserted record) your
echo
-command in
after_insert()
-hook does not have any effect on the newly loaded Detail View page, I guess.
Possible Solution
So, your task is to pass your
$message
from
after_insert()
-hook into the Detail View and alert it once (=not on every further load of detail view).
What about the following:
- In
TABLENAME_after_insert()
-hook populate a $_SESSION
-variable with your message
- In
TABLENALE_dv()
-hook, if $selectedID
exists, check if that $_SESSION
-variable is defined.
- If it is, append your
<script>...</script>
to $html
variable...
- and unset the
$_SESSION
variable (to avoid another alert on next DV-opening)
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readability
AppGini 24.10 Revision 1579 + all AppGini Helper tools