Passing parameter to scheduler job

Hello,
how can i pass parameter into a custom function on scheduler?

currently…

array_push($job_strings, ā€˜custom_import’);
function custom_import()
{
//logic here
//return true for completed
$GLOBALS[ā€˜log’]->FATAL(ā€˜TEST’);
return true;
}
wanted…

array_push($job_strings, ā€˜custom_import’);
function custom_import($parameter)
{
//logic here
//return true for completed
$GLOBALS[ā€˜log’]->FATAL('TEST: '.$parameter);
return true;
}

Selecting the function on scheduler it works but i would like to add parameters to function.
JOBURL(which path???) or what else?

How can do that when creating new scheduler?

Thanks

I’d suggest just creating several scheduler jobs which call the same function with different parameters.

Hello,
Thanks but it’s not clear for me also due to lack of documentation. .

Could you provide me the right sintax to set schedule job url and calling function with parameters?

Thanks

You can’t actually pass a parameter to the actual job, but you can do this:


$job_strings[] "firstScheduler";
function firstScheduler(){
    $sched = new TheScheduler();
    $sched->schedulerFunction("parameterOne");
}
$job_strings[] "secondScheduler";
function secondScheduler(){
    $sched = new TheScheduler();
    $sched->schedulerFunction("parameterTwo");
}
class TheScheduler
{
    function schedulerFunction($parameter){
        
    }
}
1 Like

Hello,
i’ve tried your example code like this:

<?php array_push($job_strings, 'dbgroup_import'); function dbgroup_import() { $sched = new TheScheduler(); $sched->schedulerFunction("parameterOne"); } class TheScheduler { function schedulerFunction($parameter){ $GLOBALS['log']->FATAL($parameter); return true; } } seems executed well but just after log shows this: Thu Jan 19 17:31:01 2017 [13457][1][FATAL] parameterOne Thu Jan 19 17:31:01 2017 [13457][1][FATAL] Job 6a2efe70-5630-ed0e-42bb-5880e9b59e1e (ERP Import Data) failed in CRON run and error.log: PHP Notice: Undefined index: SchedulersJobs in /var/www/html/SCMDEMO1/include/SearchForm/SearchForm2.php on line 129, referer: http://172.20.1.83/SCMDEMO1/index.php?module=Schedulers&action=index en_US.xxx.php is: $mod_strings['LBL_DBGROUP_IMPORT'] = 'D.B. Group Import Data'; What i'm missing? Thank you

Got IT…

return true must be placed in function…not in class…

Thanks again to point me in teh right direction…