Thursday 3 February 2022

How to give edit access of file attachments(content document ) to user ?

Use case - User should have ability to make change in file name which are getting created from third party. We are getting patient details from a hospitals using a third parry referral source. so Leads with all file attachments created in salesforce. Once lead is converted user should be able to change file name attached to opportunity/Lead.

Implementation :When content document/content document link created thorough integration, by default it must be provided ShareType as "V" that is why all the users can view, only admin can have access  to modify. 

https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_contentdocumentlink.htm

We need to update sharetype as "I" so that whoever has access to modify opportunity can modify file name.

There are different approach to achieve it. I did it through flow.

Step -1 Create Record Triggered flow

Step - 2 Entry criteria - when lead is converted, so IsConevrted is true

Step - 3 Query Content Document Link record List and pull shareType

Step -4 Have a loop running Content Document Link List.
Step -5   Get content Id from loop and update ShareType and sore updated content document in a list to update at a time.
Step 6- Check if Content Document list is not empty 
Step - 7 Update content Document List

Here is the total flow













No comments: