run php program after save

Hi all

I would like to run a database clean-up php program when a record is saved, Presently it is set to run every minute which is fine but impractical, as it really only needs to be run after a update or save has been submitted.

Anyone know how i can accomplish this ?

Hello degar007

Maybe you can use the extension framework. In this case the Logichook part.

you can read some details here in this link:

http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_6.5/Extension_Framework/Extensions/LogicHooks/

hope it helps!

regards,

1 Like

Thank you very much for your reply, I will definitely have a look at this article.

any other help would be greatly appreciated !

You can use a logic hook, after_save

see documentation here men:

http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.9/Architecture/Logic_Hooks/

1 Like

Hi ALL !

I would like to thank you very much for your help. Just in case anyone else has this question, this is what I did as a test and it worked (sending me an email after a lead had been saved).

created a hook in /custom/modules/Leads/logic_hooks.php


$hook_array['after_save'][] = Array(1, 'emailme', 'modules/leads/emailme.php', 'c_email', 'f_email');

created /modules/leads/emailme.php


<?PHP

class c_email
{
    function f_email()
	{
	//some simple code to send me a email, or to do some other stuff !
	}
}
?>

Thanks again !!!

Just not forget to type the $hook_version = 1; before declarations of the logic hook

will do, thanks !