0

I am trying to schedule a job to run several times a day.

It's a Utilization job which is part of the FinancialForce PSA application. The UtilizationScheduler class has this signature:

global class UtilizationScheduler implements System.Schedulable {
    global UtilizationScheduler(pse__Utilization_Calculation__c calc) {

    }
    global UtilizationScheduler(pse__Utilization_Calculation__c calc, String cronDayParm) {

    }
    global void execute(System.SchedulableContext sc) {

    }
}

I think I am close with:

System.schedule('Utilisation 1am 1pm 5pm', '0 0 1,13,17 * * ?', new UtilizationScheduler());

But I get an error: Invalid type: UtilizationScheduler by Executing Anonymous Apex from the Developer Console.

How should I call the UtilizationScheduler Class? How do I tell it what Utilization Calculation (a custom object in FinF PSA) to use?

Apologies - this is my first foray into Apex code. Help greatfully received!

1 Answer 1

2

Classes installed from a package have a namespace. To call it, you should use the appropriate namespace:

System.schedule(
  'Utilisation 1am 1pm 5pm', 
  '0 0 1,13,17 * * ?', 
  new namespace.UtilizationScheduler()
);

I'm not familiar with what the namespace for this package is, but you can find it in Setup > Package Manager. Just replace namespace. with the appropriate namespace for the class.

3
  • Amazing! Thank you @sfdcfox! The namespace is pse (if you care!) I'm now getting the error Constructor not defined: [pse.UtilizationScheduler].<Constructor>. I need to give it the pse__Utilization_Calculation__c calc somehow. Any thoughts?
    – StevieP
    Commented Jan 7, 2022 at 18:28
  • @StevieP you can try to query one from the database, [select id from pse__Utilization_Calculation__c]; or you can create one manually, pse__Utilization_Calculation__c calc = new pse__Utilization_Calculation__c(); Make sure populate any required fields.
    – sfdcfox
    Commented Jan 7, 2022 at 18:34
  • Boom! pse__Utilization_Calculation__c calc = [select id from pse__Utilization_Calculation__c where Name='MyUtilCalcName'] I owe you a beer!
    – StevieP
    Commented Jan 7, 2022 at 18:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .