Hi,
That sounds a lot like you want to add something in the tablename_after_insert and tablename_after_update hooks. In the hook, you do your select from the table that has your subject. The body of the email would have the hyperlink to the added record.
I added a button on a table dv page to redirect to another page (php file) that does all the work. A trick at that point is that I pass the current record in the querystring to that page. This uses the Helper library from Bizzworxx (AppGiniDetailView) to add the button.
Code: Select all
var targetRootURL = "hooks/send_email.php?recID=";
var targetURL = targetRootURL.concat($j( 'input[name=SelectedID]' ).val()); // This adds the current record ID to the querystring
var dv = new AppGiniDetailView();
var actionbuttons = dv.actionbuttons;
var group = actionbuttons.addGroup("Actions");
group.addLink("Send Tow Request", targetURL, Variation.Primary, "send");
In the target page, I have
Code: Select all
$recID = $_GET['recID']; // This reads in the current record ID from the querystring
$form_id = sqlvalue("SELECT id FROM Tablename WHERE id = '{$recID}'"); // This gets data for the current record
// I store the root URL of our home page in a table, we need that for the link in the body
$home = sqlvalue("SELECT Home FROM ConfigKeys LIMIT 1");
// This builds the email header
$to = sqlvalue("SELECT Request_To FROM ConfigKeys LIMIT 1");
$from = sqlvalue("SELECT Request_From FROM ConfigKeys LIMIT 1");
$subject = sqlvalue("SELECT Request_Subject FROM ConfigKeys LIMIT 1")." - ".$recID;
// This builds the body with the link to the record
$body = sqlvalue("SELECT Request_Body FROM ConfigKeys LIMIT 1").
$lf.$lf.$record.
$lf.$lf."To view this record please go to: ".$lf.
$home.
"Tablename_view.php?SelectedID=$recID".$lf;
I ended up using php to send the email. I think there is an API in AG to do that, probably cleaner, but I had already done this.
I needed to do the button. You can add this directly in the hook I would think, simpler, not having to mess with the button part or the querystring part.
Good luck.
~Paul