Differences in after_update / after_insert functions

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
Yilmaz
Veteran Member
Posts: 32
Joined: 2013-01-24 16:58

Differences in after_update / after_insert functions

Post by Yilmaz » 2013-02-19 13:52

Dear forum,

I use the tablename_after_insert func for sending an email to dedicated user when a new record is inserted. This works very well. I have embedded also a link in the email for the entered record:

Code: Select all

function ap_main_after_insert($data, $memberInfo, &$args){

$id = $data['id'];
$bezirk = $data['district_id'];
... //all other table fields
...
$messageData .= "Bezirk                  : $bezirk  \n";
$messageData .= "Start VK Periode   : $startvk  \n";
... // all other email messages
$messageData .= "Link to record : http://intranet2/werbeplaner/ap_main_view.php?SelectedID=$id\n\n"; //allthough "SelectedID" is written with big capital it works!!!!!!! Otherwise not!!!
In the mail I can see very well the values for example "district_id" and "id" in the URL.

Now I want to do the same issue via after_update func when an existing record is changed/updated. So
I pasted the same code above (with some textual changes in messagedata) in the function tablename_after_update.

Unfortunatelly the result is not the same, i.g. the primary key id is not passed, so that for example the URL has not the record id at the end of the link http://.../SelectedID=123

I found in tablename_dml.php the section where the functions after_insert and after_update are called. There are differences due to the calls for the IDs: "$recID" and "$data['id']".

I tried to replace the $data['id']s in the section for after_update by the $recID like in the section for after_insert, but the result was the same as above (without passing the record id).

I hope I could explain my problem.

What could be the reason?

Many thanks in advance
Yilmaz

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Differences in after_update / after_insert functions

Post by a.gneady » 2013-02-23 06:36

Try $data['selectedID'] ... this should work.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

Yilmaz
Veteran Member
Posts: 32
Joined: 2013-01-24 16:58

Re: Differences in after_update / after_insert functions

Post by Yilmaz » 2013-02-26 13:22

Dear Ahmad,

thanks for your reply. I tried it with $data['selectedID'] but still no success! Any other idea?

function ap_main_after_insert($data, $memberInfo, &$args){

$id = $data['selectedID'];
$bezirk = $data['district_id'];
... //all other table fields
...

Post Reply