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!