Limit fields sent by email

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
benzoD
Veteran Member
Posts: 69
Joined: 2013-01-31 21:16

Limit fields sent by email

Post by benzoD » 2013-09-11 20:39

I've successfully used the email code from the tutorial to have emails sent to a user when inserting records. The issue I'm having is that I don't want all of the fields in the table to be sent, as some are simply for internal use and I'd like for it to be as uncluttered as possible.

The code I'm working with is this:

Code: Select all

         foreach($data as $field => $value){
                $messageData .= "$field: $value \n";
I know that the foreach is looping through the object to display every field contained within and assigning it to $message data, but I'd like to have only 5 of the 10 fields sent. How do I get only certain parts of the $data to be displayed in my emails?

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

Re: Limit fields sent by email

Post by a.gneady » 2013-10-14 01:19

Try this:

Code: Select all

$fields_to_send = array('field1', 'field3', 'field5');
foreach($fields_to_send as $field){
    $messageData .= "$field: {$data[$field]} \n";
So, instead of looping on $data which sends all fields, you're looping only on the fields specified in $fields_to_send
:idea: AppGini plugins to add more power to your apps:

benzoD
Veteran Member
Posts: 69
Joined: 2013-01-31 21:16

Re: Limit fields sent by email

Post by benzoD » 2013-11-04 14:17

Just seeing this now, but I will give it a try and report back. Thanks for the reply!

benzoD
Veteran Member
Posts: 69
Joined: 2013-01-31 21:16

Re: Limit fields sent by email

Post by benzoD » 2014-02-17 15:50

Just confirming that this works well!

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

Re: Limit fields sent by email

Post by toconnell » 2014-04-28 17:22

OK.. I want to do the same thing but I want to show a 'look up field' without just the record number.. so I need to do an inner join on one of the fields.. How do I make sure I can show the actual look up value and not the record ID that shoes.. in this situation?

For example.. county 5 is Brevard.. I want the message data to show Brevard, not the 5 that shows now. So using this code above, where do I put the inner join of the table to pull the actual data out?

Thanks,
Tina O'Connell
Web Dev & Appgini FAN

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 356
Joined: 2013-03-21 04:37

Re: Limit fields sent by email

Post by peebee » 2014-04-28 23:31

You could try LEFT JOIN - ref: http://www.w3schools.com/sql/sql_join_left.asp

Whilst I have no idea what your table and field names are, you can hopefully get the general idea by fiddling around with this guesswork example below......

$county=sqlValue("select c.countyID from routes r left join countys c on c.id=r.countyref where yourprimkey='".makeSafe($selected_id)."'");

then....

$messageData .= "County: $county" \n;

Hopefully that will work for you.

Post Reply