You need to sign in to do that
Don't have an account?
jishan roy
Trigger for latest comment update then update the case field which is a custom field (Latest Comment).
here is my code:
for(case c : lstCase){
if(c.Latest_Comment__c==Null||c.Latest_Comment__c!=Null){
c.Latest_Comment__c=c.Comments;
}
}
But this will work only when create a new case when update comment in that case it will not getting output.
If anybody know then please help me out of this problem
Thanks in Advance.
for(case c : lstCase){
if(c.Latest_Comment__c==Null||c.Latest_Comment__c!=Null){
c.Latest_Comment__c=c.Comments;
}
}
But this will work only when create a new case when update comment in that case it will not getting output.
If anybody know then please help me out of this problem
Thanks in Advance.
Have you mention the before update event in the trigger?
If not, keep the before update in the trigger and try.
Thanks!!
Here is my handler class:
public class CaseTriggerHandler {
public static void updateComments(list<case> lstCase){
for(case c : lstCase){
if(c.Latest_Comment__c==Null||c.Latest_Comment__c!=Null){
c.Latest_Comment__c=c.Comments;
}
}
}
}
This is trigger:
trigger latestCommentTrigger on Case (after update,after insert,before insert,before update) {
if(trigger.isbefore&&(trigger.isupdate||trigger.isinsert)){
CaseTriggerHandler.updateComments(trigger.new);
}
}
You need to write a trigger on casecomment object.
try with below code. If this helps, Please mark it as best answer.
Thanks!!