• Anurag Nanda
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I want to create a trigger on Note object.
When a new note is created it will update a custom field on Case object with LastModifiedDate of New note.

My code is :

trigger UpdateLastModifiedDate on Note(after insert) {
    
     List<Case> caseUpdate = new List<Case>();
    for(Note n : Trigger.new){
        if(n.ParentId != null && n.ParentId.getSObjectType() == Case.sObjectType){
            Case cas=new Case(Id=n.parentId,Last_Modified_Date1__c=n.CreatedDate);
            caseUpdate.add(cas);

       } 
    }
    
    if(caseUpdate.size()>0){
        update caseUpdate;
    }
}
I want to create a trigger on Note object.
When a new note is created it will update a custom field on Case object with LastModifiedDate of New note.

My code is :

trigger UpdateLastModifiedDate on Note(after insert) {
    
     List<Case> caseUpdate = new List<Case>();
    for(Note n : Trigger.new){
        if(n.ParentId != null && n.ParentId.getSObjectType() == Case.sObjectType){
            Case cas=new Case(Id=n.parentId,Last_Modified_Date1__c=n.CreatedDate);
            caseUpdate.add(cas);

       } 
    }
    
    if(caseUpdate.size()>0){
        update caseUpdate;
    }
}