You need to sign in to do that
Don't have an account?
Kristen Hudgens 9
Cross Object Field Update Trigger
I have the need to update a field on a case, based on some values when a task is created on the case.
If the Subject of the task is 'Package Sent to Owner', I need to update the field OwnerPackageSentDate__c (on the case) to Todays date.
Any help is appreciated.
If the Subject of the task is 'Package Sent to Owner', I need to update the field OwnerPackageSentDate__c (on the case) to Todays date.
Any help is appreciated.
Which action of trigger are you using after update or before update?
Remember you can pass primitive data types only as parameters.
@future
public static methodname(){
//do the stuff here
}
trigger TaskTrigger on Task (after insert) {
List<Case> caseList = new List<Case>();
for(Task tsk : Trigger.new){
if(tsk.whoId != null && tsk.whoId.getSObjectType() == Case.sObjectType && 'Package Sent to Owner'.equals(tsk.Subject)){
Case tskCase = new Case(Id = tsk.whoId);
tskCase.OwnerPackageSentDate__c = Date.Today();
caseList.add(tskCase);
}
}
Database.update(caseList);
}
You would need to move this to a class & then invoke in trigger.