• siree ganti
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
Hi All,
The following code doesn't seem to work.  Trying to calculate daily total for support cases closed, average month-to-date (mtd), average year-to-date ytd for reporting purposes.  Please help!!
here's the code:

global class batchA0806 implements Database.Batchable<sObject>
{
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        Integer DailyTotal = SELECT COUNT() FROM Cases where ClosedDate=TODAY ;
        Integer a = SELECT COUNT() FROM Cases where ClosedDate=THIS_MONTH;
        Integer b = SELECT COUNT() FROM Cases where ClosedDate=THIS_YEAR;
        return Database.getQueryLocator(query1);
    return Database.getQueryLocator(a);
    return Database.getQueryLocator(b);
    }
   
    global void execute(Database.BatchableContext BC)
    {
         
             mtd = a/THIS_MONT;
         ytd = b/THIS_YEAR;
             update mtd;
             update ytd;
             update DailyTotal;
    }   
    global void finish(Database.BatchableContext BC)
    {
    }
}
Hi All,
How can I update a field value for a particular sObject in a List of sObjects? I'm trying to update the status of a task to 'Completed' if the corresponding opportunity status is set to 'Closed Won' by the user.
Thanks much!
 
Hi All,
Following apex trigger fails to create the task as intended. I was able to get rid of dml exceptions, but still no task.  Please advise.

trigger addNewTaskToAccountOwner on Opportunity (after insert, after update) {
for (Opportunity myOppty : Trigger.new) {
if ((myOppty.StageName != 'Closed Won') &&(myOppty.StageName!='Closed Lost') && (myOppty.Account != NULL)) {
Task myTask = new Task();
myTask.OwnerId = myOppty.Account.OwnerId;
myTask.Subject = 'Automatic task';
myTask.Status = 'Not Started';
myTask.Priority = 'Normal';
insert myTask;
}
}
}


 
Hi All,
How can I update a field value for a particular sObject in a List of sObjects? I'm trying to update the status of a task to 'Completed' if the corresponding opportunity status is set to 'Closed Won' by the user.
Thanks much!
 
Hi All,
The following code doesn't seem to work.  Trying to calculate daily total for support cases closed, average month-to-date (mtd), average year-to-date ytd for reporting purposes.  Please help!!
here's the code:

global class batchA0806 implements Database.Batchable<sObject>
{
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        Integer DailyTotal = SELECT COUNT() FROM Cases where ClosedDate=TODAY ;
        Integer a = SELECT COUNT() FROM Cases where ClosedDate=THIS_MONTH;
        Integer b = SELECT COUNT() FROM Cases where ClosedDate=THIS_YEAR;
        return Database.getQueryLocator(query1);
    return Database.getQueryLocator(a);
    return Database.getQueryLocator(b);
    }
   
    global void execute(Database.BatchableContext BC)
    {
         
             mtd = a/THIS_MONT;
         ytd = b/THIS_YEAR;
             update mtd;
             update ytd;
             update DailyTotal;
    }   
    global void finish(Database.BatchableContext BC)
    {
    }
}
Hi All,
Following apex trigger fails to create the task as intended. I was able to get rid of dml exceptions, but still no task.  Please advise.

trigger addNewTaskToAccountOwner on Opportunity (after insert, after update) {
for (Opportunity myOppty : Trigger.new) {
if ((myOppty.StageName != 'Closed Won') &&(myOppty.StageName!='Closed Lost') && (myOppty.Account != NULL)) {
Task myTask = new Task();
myTask.OwnerId = myOppty.Account.OwnerId;
myTask.Subject = 'Automatic task';
myTask.Status = 'Not Started';
myTask.Priority = 'Normal';
insert myTask;
}
}
}