I am stuck on three errors that I cannot seem to diagnose in an Apex class and trigger combination. The class is below:

public class DelegatedUserSetup {
    void setObjectives(User[] users) {
        System.enqueueJob(new SetObjectivesAsQueueable(users));

     public class SetObjectivesAsQueueable implements System.Queueable{
         User[] users; 
         SetObjectivesAsQueueable(User[] users) {this.users = users;}

         void execute(System.QueueableContext qc) {
             Objectives__c[] masterObjectives = 
             [SELECT Id,Name,Duration__c,Minutes__c,OwnerId,URL__c,Week__c,Start_Date__c,Type__c 
              FROM Objectives__c WHERE MASTER__c = true];

             Objectives__c[] assignedObjectives = new List<Objectives__c>();

            for(User u : this.users){ // every user gets ea masterObjective
                for (Objective__c masterObjective : masterObjectives) {
                    assignedObjectives.add(new Objective__c (
                        OwnerId = u.Id,  // assign to user
                        Name = masterObjective.Name,
                        Status__c = 'Not started',
                        Duration__c = masterObjective.Duration__c,
                        Minutes__c = masterObjecive.Minutes__c,
                        URL__c = masterObjective.URL__c,
                        Week__c = masterObjective.Week__c,
                        Start_Date__c = masterObjective.Start_Date__c,
                        Type__c = masterObjective.Type__c,
                        MASTER__c = false
             insert assignedObjectives;  // if none, no DML burnt

The class error is that I have an unexected token "public" on line 5 and DelegatedUserSetup.SetObjectivesAsQueueable: Overriding implementations of global or public interface methods must be global or public: void System.Queueable.execute(System.QueueableContext)

the trigger is below:

trigger insertTasks on User (after insert) {
    new DelegatedUserSetup().setObjectives(
      [SELECT Id 
        FROM User 
        WHERE Onboarding__c = TRUE AND
              Id IN: Trigger.newMap.keySet() ]
    ); // ensure only current trigger context

The error here is:

Method does not exist or incorrect signature: void setObjectives(List<User>) from the type DelegatedUserSetup

Any guidance is appreciated!

  • Welcome to SFSE! In general, taking the time to make sure your indentation is consistent (in the code you post here as well as in your IDE) makes things easier to read. In some cases like this, it can also make it easy to see where the issue is. Adrian's answer is spot on, and it becomes fairly evident with proper indentation.
    – Derek F
    Commented Feb 12, 2021 at 17:43

1 Answer 1


You didn't close your first method. If you want to make this method available for consumption from elsewhere, it must also be made public.

public void setObjectives(List<User> users) {
    System.enqueueJob(new SetObjectivesAsQueueable(users));
} // <-- MISSING
  • sheesh -- it was my answer that had the syntax error
    – cropredy
    Commented Feb 12, 2021 at 19:08
  • Oopsie! Not too late to fix. :)
    – Adrian Larson
    Commented Feb 12, 2021 at 19:22

You must log in to answer this question.

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