You need to sign in to do that
Don't have an account?
Staci
update case comment and case in trigger
I'm looking to create a case comment and update some of the case fields in a trigger. This is what I have so far, but I get an error saying the record is read-only ( These lines c.Status = 'Pending'; c.Priority = 'Low'; c.CW_Type__c = 'Task';)
trigger CW_DSS_CaseTrigger on Case (after update) { if(CWcheckRecursive.runOnce()) { List<Case> cwCasesUpdated = new List<Case>(); List<caseComment> caseCommentList = new List<caseComment>(); for (Case c: Trigger.new) { caseComment cc = new caseComment(); if(c.Macros__c == 'Application Support information'){ cc.parentid = c.ID; cc.commentbody = 'For application (DSSi and Relay Server) support and troubleshooting requests, please provide the following information.'+'\n' + 'Minimum DSS Ticket Information requirements:'+'\n' + 'Site Name:' +'\n' + 'Site Contact: (For possible Site IT related issues)' +'\n' + 'DSSi Software Version:' +'\n' + 'Problem/Inquiry:' +'\n' + 'Troubleshooting Steps Taken:' +'\n' + 'This information is required with all DSS support requests. Failure to provide this requested information may delay your request.'; cc.ispublished = true; cwCasesUpdated.add(c); casecommentlist.add(cc); } if(c.Macros__c == 'Blackbox - Out of Scope'){ cc.parentid = c.ID; cc.commentbody = 'Blackbox data requests can only be processed for incidents that occur involving driver fatigue, personal or property damage' +'\n' + 'and injury related to fatigue or distraction and operator tampering. The DSS is not to be used for disciplinary actions for mine safety violations.'+'\n' + 'This eliminates sites wanting blackbox video for mine safety infractions, evidence of medical related injuries or diagnostic reasons.' +'\n' + 'This is to only be used if necessary to add evidence, clarify or discovery information about an incident or accident involving fatigue and/or distraction.'; cc.ispublished = true; c.Status = 'Pending'; c.Priority = 'Low'; c.CW_Type__c = 'Task'; casecommentlist.add(cc); } } insert caseCommentList; } }
https://trailblazers.salesforce.com/answers?id=9063A000000iluwQAA
https://developer.salesforce.com/forums/?id=906F00000008yMqIAI
I hope it helps.