Hi,
Is it possible to automatically perform a task after a user has added a new record?
For example, once a user as added a new record to the database, I would like to e-mail a copy of what was added to an e-mail address.
Is this possible??
Thanks,
Michael
Hello,
You can put your email code in on_after_insert and it will be called after insert.
$e["on_after_insert"] = array("my_after_insert", null, true);
$grid->set_events($e);
function my_after_insert($data)
{
// $data["id"]; will hold new inserted id
}
You can take reference from demos/editing/custom-events.php
Hi Abu,
Whenever I use the line of code:
$grid->set_events($e);
The website doesn't show (fails) is set_events() a new feature??
I purchased the software less than 12 months ago.
Thanks,
Michael
Hello,
The set_events() function is from version 1.
Make sure $grid variable is present and set to
$grid = new jqgrid();
If you are using some different variable, you need to call set_events against that var.
Hi Abu,
I've managed to get the screen to display again – my error!
I cannot however get the program to perform a task after a record has been added.
Here is the code:
$e["on_after_insert"] = array("my_after_insert", null, true);
$g->set_events($e);
function my_after_insert($data){
$data["id"]; will hold new inserted id
}
I've also gone to your demo software for "Custom Events" and this also will not perform an event after and record has been inserted – that is not on the server side".
Can you help?
Thanks,
Michael
Here is the sample usage:
$e["on_after_insert"] = array("after_insert", null, true);
$grid->set_events($e);
You can code your email logic inside after_insert.
You can also debug it by putting phpgrid_error('test'); inside function. It would prompt the message on grid.
function after_insert($data)
{
/*
These comments are just to show the input $data format
Array
(
[client_id] => 99
[params] => Array
(
[client_id] =>
[name] => Test
[gender] => male
[company] => Comp Test
)
)
*/
ob_start();
print_r($data);
$str = ob_get_clean();
phpgrid_error($str);
}