+ Start a Discussion
bsil bsilbsil bsil 

Update one task based on other task

HI All,

I am struggling with updation os one task record based on other task......

here is
i have task1 and task2.

task 1 is related to account and task2 is related to custom object

here we have on common field in task call accid.
in accid we have account id in both tasks.

here my requirment is to task2 when i am going to update task1............

Please Can anyone suggest me it's urgent 

I have developed the below code

trigger TaskAU on Task (before update)
    set<string> vProjAccId = new set<string>();
    for(Task t : trigger.new)
    list<Task> vLstTask = [SELECT Id,ProjectAccountIDs__c,ActivityDate,Priority,Status,Subject,OwnerId FROM Task
                        where ProjectAccountIDs__c IN : vProjAccId];
   // Task vTask;   
   // list<task> vLstTasks = new list<task>();               
    for(Task tas : trigger.new)
        //vTask = trigger.oldMap.get9tas.id);
        for(Task vTas : vLstTask)
           if(vTas.ProjectAccountIDs__c == tas.ProjectAccountIDs__c)
              vTas.ActivityDate = tas.ActivityDate;
              vTas.Priority = tas.Priority;
              vTas.Status = tas.Status;
              vTas.Subject = tas.Subject ;
    //update vLstTask;
Carolina Ruiz MedinaCarolina Ruiz Medina
Hi bsil bsil

what is exactly the issue that you are having? 
Looking at your code I could see that maybe I would use maps instead list,.. but this is another thing. Also maybe your code needs to run in update too, instead on insert only?
 But what is the exact error you are are getting?. there is code that is  commented out, are you using it ? , where is exactly the error that you get? In wich part of the code?

Another thing to have in mind at the time to implement a trigger is the possibility to hit governor limits, then the "updation" of the related task has to be sensitive as you can only process 10000 records as a result of a DML. 

Looking forward hearing from you.