function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anurag NandaAnurag Nanda 

trigger on note object to update case object field

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;
    }
}
ASIF ALIASIF ALI
Hiiii Anurag, 
Unfortunately we cannot create a trigger on the note object in salesforce, I tried to do this task in process builder too but there is no option for Note object and we cannot use flow too.
Anurag NandaAnurag Nanda
Hi Asif,

But it is possible to write trigger on ContentDocument object, which stores all the data of a note record.