Concepts or coding lessons of Salesforce that you can implement easily

5 Simple Steps to Delete Salesforce files Owned by Other Users

In Lightning Experience, we have limitation who can Delete Files - 
Only a File Owner and Users with the “Modify All Data” permission can delete all Files !!!
This is working as designed for Lightning version.

We recently moved from Salesforce Classic to Lightning Experience .

While transition to Lightning Experience, we have enabled "Save Email-to-Case attachments as Salesforce Files" Email-to-Case Settings and also enabled "Files uploaded to the Attachments related list on records are uploaded as Salesforce Files, not as attachments" from Salesforce Files Settings.

So whenever we receive attachments in Email-to-Case or Upload any attachment into Salesforce, it automatically convert into files by Salesforce.

We have business process setup where we have to delete some confidential files received via Email-to-Case. In this blog I am going to explain how I achieve this.

To meet requirement, we have only one option available which is Customization.

I have used one idea, "Whenever Case Owner changes then Set that Owner as an Owner for Files of that Case".

If you similar business process then Follow below 5 Simple Steps :

1. Create Apex class namely "ContentDocumentController" with Without Sharing and add below code:

2. Create Process builder on Case object for INSERT / UPDATE event.
3. Define Criteria for this Action Group : 
 AND(
NOT(ISNEW() ),
ISCHANGED([Case].OwnerId ),
BEGINS([Case].OwnerId, "005") 
)
4. Set below things as Immediate action:




5. Activate Process Builder.

Enjoy! If you have any questions, comments etc. please feel free to let me know. As always, please feel free to get in touch me as I would be more than happy to assist you with any of your Salesforce development needs.


Subscribe blog for More updates !!! 


Read More: WhatsApp on Salesforce Integration in 5 Steps
                    Which Salesforce API Do I Use in Integration?
                    When To Use Salesforce REST API  
                   When To Use Salesforce SOAP API 
                   When To Use Salesforce Bulk API 

Latest Salesforce Interview Questions and Answers:
loading...

No comments:

Post a Comment