⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Send email on record change



Devin Young

Devin Young
  • profile picture
  • Member

Posted 03 February 2013 - 03:36 AM

Maybe it's the lack of sleep, but I'm struggling with what seems to be a simple task. Essentially I want to send an email to an admin when a record is updated via grocery crud. This email would only need to contain the new record--basically just saying "hey just a heads-up, this was changed in your database." Would it be easiest to do this directly in the grocery crud model (bad practice, I know)? Or via the controller calling the model? Thanks.

victor

victor
  • profile picture
  • Member

Posted 03 February 2013 - 17:00 PM

you can use a callback function called 'callback_after_update'
more info here: www.grocerycrud.com/documentation/options_functions/callback_after_update

Devin Young

Devin Young
  • profile picture
  • Member

Posted 05 February 2013 - 16:25 PM

This worked perfectly, thanks!


Yogesh Kamat

Yogesh Kamat
  • profile picture
  • Member

Posted 01 April 2013 - 07:35 AM

Hi guys,

 

i am sending an email on callback_after_update and callback_after_insert..

Email View is sent without any issue... but not able to send any columns from the updated or inserted record into the email view.

 

just stuck on this only


Yogesh Kamat

Yogesh Kamat
  • profile picture
  • Member

Posted 01 April 2013 - 08:15 AM

Actually i am able to pass array successfully and show all fields when i add and update. 

 

Just one issue now.. there is one field receipt_no which is sent as subject only when a record is inserted ... but on update this field does not get passed.

 

This field is hidden and autogenerated. this autogeneration should happen only while inserting record.. so i have not added it to the edit_fields function.

 

i guess that is the reason its not there in the array whilst  doing callback on update any fixes..


davidoster

davidoster
  • profile picture
  • Member

Posted 01 April 2013 - 09:16 AM

Actually i am able to pass array successfully and show all fields when i add and update. 

 

Just one issue now.. there is one field receipt_no which is sent as subject only when a record is inserted ... but on update this field does not get passed.

 

This field is hidden and autogenerated. this autogeneration should happen only while inserting record.. so i have not added it to the edit_fields function.

 

i guess that is the reason its not there in the array whilst  doing callback on update any fixes..

 

 

I don't quite follow your thinking...

Ok, you auto generate this field. This is not stored anywhere while inserting a new record? On an existing field?


Yogesh Kamat

Yogesh Kamat
  • profile picture
  • Member

Posted 01 April 2013 - 09:19 AM

I don't quite follow your thinking...

Ok, you auto generate this field. This is not stored anywhere while inserting a new record? On an existing field?

 

 

Autogenerated field is stored in database.. but is hidden in the form..