URGENT- How to send an email ONLY IF one field is changed?

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
User avatar
toconnell
Veteran Member
Posts: 204
Joined: 2013-04-09 19:29
Location: Oklahoma City, OK
Contact:

URGENT- How to send an email ONLY IF one field is changed?

Post by toconnell » 2014-04-23 21:10

I have a field called 'Active' in my table compliance.
I would like to send an email only if the Active field is changed from TRUE to FALSE or from FALSE to true..

In PHP how do I code the 'if' condition properly?

I am most grateful for any help you can lend.

I have read all the php manuals I could find and most only show you how to compare.. I could compare old data with new data.. but not sure how to capture and compare old data in the hooks. As php does not allow more than one return per function from what I have read. I have tried making a global variable in the BEFORE UPDATE and BEFORE INSERT hooks on this table and dropping it into a log with no luck. Capturing the old data to compare it to the new data (no problem getting the new data) is the hard part. I cannot seem to get the old data before the update was done.

Any suggestions, Please post fast!
Tina O'Connell
Web Dev & Appgini FAN

KSan
AppGini Super Hero
AppGini Super Hero
Posts: 252
Joined: 2013-01-08 20:17

Re: URGENT- How to send an email ONLY IF one field is change

Post by KSan » 2014-04-24 06:44

How about adding a new field to your db called ActiveOld. Keep it hidden.

In after insert hook set ActiveOld = Active

In after update check if Active is equal to ActiveOld or not (so you get your answer) and then set ActiveOld = Active

Hope this helps.

User avatar
toconnell
Veteran Member
Posts: 204
Joined: 2013-04-09 19:29
Location: Oklahoma City, OK
Contact:

Re: URGENT- How to send an email ONLY IF one field is change

Post by toconnell » 2014-04-24 12:28

It sends the email whether the active field is the only one changed or not..

So.. nope.. not working.. I am going to PM you my full code.. and email. Thanks, Tina
Tina O'Connell
Web Dev & Appgini FAN

Post Reply