• Nikhil Sagar
  • NEWBIE
  • 30 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 2
    Replies
trigger DeleteContentDocument on ContentDocument (before delete) 
{
    for(ContentDocument cd: [SELECT Id, FileExtension FROM ContentDocument 
                             WHERE FileExtension = 'snote' and Id =: trigger.oldMap.keyset() ])
    {
        Profile adminId = [SELECT Id from Profile where Name='System Administrator' LIMIT 1];
        if(System.Trigger.IsDelete && UserInfo.getProfileId() != adminId.Id)
        trigger.oldMap.get(cd.Id).adderror('Note Cannot be deleted');                         
    }
}