Setup CRON job where I can use SugarCRM framework

Hello,

I need to create a script that runs every day, grabs emails from inbox, parses these, and if it finds the info needed, duplicates some entries in SugarCRM, sets some fields etc.

I need to use the SugarCRM framework, code like:

$account = new Account();

$account->retrieve($invoice->billing_account_id);

What's the preffered way to include SugarCRM into cron script?

Thanks!

  • Hello Vaclav,

    You would most likely want to setup a Scheduler Job. Here is some documentation from our Developer Guide on how to accomplish this. This should get you going in the right direction.

    Kind Regards,

    Jason Smith

  • Thanks, looks pretty straightforward. What is the way to test the job while in development? Thanks!

  • Hello Vaclav,

    After you create and install the scheduler, just create and activate it in Admin > Scheduler and you should be good to go. This is of course assuming that you have cron running and setup the cronjob for Sugar. This documentation should help you set that up.

    Kind Regards,

    Jason Smith

  • Thanks Jason - I meant when developing the code, I need to run it and see the output - it doesn't seem practical to wait for cron to run...

    thanks

    V.

  • Hello Vaclav,

    Alternatively, you can just go to the cron.php file and execute it. Usually something like "php cron.php" from the command line will do the trick.

    Kind Regards,

    Jason Smith

  • Thanks, but I don't have access to command line... bu I think I can just add the code to some logic hook and execute it manually from somewhere, right? Or is there a better place for this?

  • Hello Vaclav,

    You could use a logic_hook I suppose but it may be best to build it onsite and test it there and then once you finish testing, use it in production. Alternatively, you can set the scheduler to run every minute. While it isn't instantaneous, it's still soon enough to perform tests. Of course this required the cronjob to run every minute.

    Kind Regards,

    Jason Smith