Page 1 of 1

After Save code no new record

Posted: Fri Dec 07, 2018 12:28 pm
by 191brian
Hi

I have some code in "After Save" to send an email when a record is updated that uses data from fields in the current record.

This code works fine when updating an existing record but fails to get data from the fields on a new record, I can see the problem is that #record_id# is not populated at this point when its a new record as when I debug it has a value of -1
Is there another reference I should use to get the record id of the new record or another way to get it to work on a new record?

The relivant part of my code is:->>>
$select2 = "SELECT * FROM works WHERE works_id='#record_id#'";
$run2 = nuRunQuery($select2);

$r = db_fetch_array($run2);
$subject = "IT Help desk: " .$r['wrk_status'] . " - " . $r['wrk_name'];

$wrknotes = $r['wrk_notes'];

$wrkuserid = $r['wrk_users_id'];
nuDebug($wrkuserid);
<<<
Thank you Brian ...

Re: After Save code no new record

Posted: Fri Dec 07, 2018 2:43 pm
by kev1n
Use #RECORD_ID# (all upper case) instead of #record_id#.
If you want to know which Hash Cookies are available you could add this to the Before Browse event of the same Form.

Code: Select all

nuDebug(nuHash());
And check it in the Debugger.