You need to sign in to do that
Don't have an account?

Trailhead's Apex Scheduler: TaskUtils not recognized?
I created a new class 'RemindOpptyOwners' per the Trailhead tutorial on Apex Scheduler, but the code will not compile, because
I transcribed this code at first, but then copied and pasted directly into the Dev console and got the same error. Why is TaskUtils not being recognized?
API Version: 37.0
'Variable does not exist: TaskUtils'Here is the code I have:
global class RemindOpptyOwners implements Schedulable { global void execute(SchedulableContext ctx) { List<Opportunity> opptys = [SELECT Id, Name, OwnerId, CloseDate FROM Opportunity WHERE IsClosed = False AND CloseDate < TODAY]; // Create a task for each opportunity in the list TaskUtils.remindOwners(opptys); } }
I transcribed this code at first, but then copied and pasted directly into the Dev console and got the same error. Why is TaskUtils not being recognized?
API Version: 37.0
public class TaskUtils
{
public static void remindOwners(List<Opportunity> lstOpp)
{
// code here for creating task to remind opportunity owner
}
Use this code :
global class RemindOpptyOwners implements Schedulable{
global void execute(SchedulableContext cntxt){
List<Opportunity> oppList = [SELECT ID, Name, OwnerId, CloseDate FROM Opportunity WHERE
IsClosed= FALSE AND CloseDate<Today];
RemindOpportunityOwners.createTaskforOpp(oppList);
}
}
Class for creating task is:
public with sharing class RemindOpportunityOwners {
public static void createTaskforOpp(List<Opportunity> oppList) {
List<Task> taskList = new List<Task>();
For(Opportunity opp : oppList) {
Task newTask = new Task(
WhatId = opp.Id,
OwnerId = opp.OwnerId,
ActivityDate = Date.today(),
Subject = 'Update Opportunity',
Description = 'Kindly close the ticket by the end of the day');
taskList.add(newTask);
}
insert taskList;
}
}
Regards,
Rahul Sharma