You need to sign in to do that
Don't have an account?
Praveen Jha
Change case status when attachment is added
When I add attachment on case, case status should change from new to working. How can i do this??
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Refer the following link how to write trigger on attachment through Developer Console
https://help.salesforce.com/HTViewSolution?id=000181538&language=en_US (https://help.salesforce.com/HTViewSolution?id=000181538&language=en_US)
And the trigger code will be
trigger UpdateCaseStatus on Attachment (after insert) {
Set<Id> stCaseIds = new Set<Id>();
List<Case> lstCasesToUpdate = new List<Case>();
for(Attachment att:trigger.new){
If(att.ParentId != null && String.valueOf(att.ParentId).startsWith('500')){
stCaseIds.add(att.ParentId);
}
}
if(!stCaseIds.isEmpty()){
for(Case cas:[SELECT Id,Status FROM Case WHERE Id IN :stCaseIds AND Status = 'New']){
cas.status = 'Working';
lstCasesToUpdate.add(cas);
}
}
if(!lstCasesToUpdate.isEmpty()){
update lstCasesToUpdate;
}
}
Regards,
Bhanu Mahesh