You need to sign in to do that
Don't have an account?
Lightning Experience: New Notes - Apex Trigger Issue
Hello,
I just created an Apex Trigger (with the help of the forum) on the Note object. The trigger works great when a new note is created from the Old-Note section but does not work when entering a note from the new lightning experience. Are the new notes being writting in a different object? Any guidance would be fantastic.
I just created an Apex Trigger (with the help of the forum) on the Note object. The trigger works great when a new note is created from the Old-Note section but does not work when entering a note from the new lightning experience. Are the new notes being writting in a different object? Any guidance would be fantastic.
trigger UpdateOppLastNote on Note (after insert, after update) { List<Opportunity> oppLstToUpdate=new List<Opportunity>(); if(Trigger.isInsert){ for(Note nt : Trigger.new){ if(String.valueOf(nt.parentId).startsWith('006')){ Opportunity opp=new Opportunity(Id=nt.parentId,Latest_Note__c=nt.Title + ': ' + nt.Body); oppLstToUpdate.add(opp); } } }if(Trigger.isUpdate){ for(Note nt : Trigger.new){ if(String.valueOf(nt.parentId).startsWith('006')){ if(nt.Body != Trigger.oldMap.get(nt.Id).Body){ Opportunity opp=new Opportunity(Id=nt.parentId,Latest_Note__c=nt.Title + ': ' + nt.Body); oppLstToUpdate.add(opp); } } } } if(!oppLstToUpdate.isEmpty()){ try{ update oppLstToUpdate; }catch(DmlException de ){ System.debug(de); } } }
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentnote.htm