Reply
Contributor
DenverDon
Posts: 3
0

Update Account field when related Case is closed

Hello,

 

Newbie question...

 

I need to update an Account date field ("Last_QA_Audit") when a Case related to that Account (via Contact) is closed, but only when that case is a particular record type. Does anyone have a snippet to share to get me started? Thank you!

 

Don

Regular Contributor
Amul
Posts: 24
0

Re: Update Account field when related Case is closed

you need to write a triiger on case object that will update the Account's Field info.

 

like

 

set<id> setAccountIds=new set<Id>();

 

trigger CaseTriggers on Account (after update) {

 

for(Case ObjCase:Trigger.new){

 if(ObjCase.Status='Closed' && ObjCase.AccountId!=null){

setAccountIds.add(ObjCase.AccountId);

}

 

}

 

 

Account[] updateAccount=[Select Id,Last_QA_Audit from Account where id:insetAccountIds];

for(Account acc: updateAccount){

acc.Last_QA_Audit=system.today();

}

 

update updateAccount;

 

 

}

 

 

 

 

 

 

//Add Record Type in above trigger logic . Please see above sample code. Also update Field API accordingly.