Is it possible to restrict certain users from deleting note entries in the Feed section? Need to restrict some users because we are having problems all the time with this.
1 Answer
There may be a simpler method, but this is what I have for now.
Write a trigger on FeedItem on before delete and stop selected users from deleting a note:
trigger feedtrigger on FeedItem (before delete) {
for(FeedItem fed: Trigger.Old){
if(fed.type == 'Contentpost'){
//Do further checks based on profile/role/Id etc and restrict the user from deleting the note.
fed.adderror('You cannot delete the note');
}
}
}
Note: You can add/ adjust type and prevent users from deleting Links, poll etc..
Refer this doc for different types of feeditem:
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_feeditem.htm
You can throw a validation at the top of the page