You need to sign in to do that
Don't have an account?
Anurag 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;
}
}
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;
}
}
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.
But it is possible to write trigger on ContentDocument object, which stores all the data of a note record.