+ Start a Discussion
BlairBBlairB 

Is it possible to trigger a field update on a custom object when a task is complete?

Hello all,

I am hoping to create a workflow rule that will assign tasks for various things. When these tasks are marked as complete, I'd like to trigger an update to a custom object that checks a checkbox to show it's been completed as well as update the date. I understand this cross object update is not possible with workflow.

Could this be possible with either process builder/flows/triggers or some combination? I am a point and click administrator at this point so I don't have any coding knowledge. Any help would be appreciated!

Thank you,

Blair
SivaGSivaG
Hi Blair,

You can use the below trigger to update the checkbox on custom object. Is that task in any way related to the custom object?

trigger TaskTrigger on Task (after update) {
  List<Custom_object__c> CustInsList = new List<Custom_object__c>();
  for(Task t : Trigger.New){
    if(t.Status == 'Complete' && t.Status != Trigger.oldMap.get(t.Id).Status){
       Custom_object__c c = new Custom_object__c();
       c.checkbox = true;
       CustInsList.add(c);
    }
  }
  if(!CustInsList.isEmpty()){
    try{
        update CustInsList;
    }
    Catch(DMLException de){
       System.debug('Exception Occurred on insert of Custom object: '+ de);
   }
  }
}

Thanks
Kumar
BlairBBlairB

It is related but not directly. The task itself is being triggered by a workflow on the detail object in a master-detail relationship and I want the trigger to update the master object once the task is complete.

I am new to coding so forgive me-could you highlight or bold the areas where I plug in our custom object/field names?

Also, could this work with a slight variation for updating a date field as well?

Thank you for your help!!