Posts

Showing posts with the label file

Salesforce Fact #776 | Error while deleting file association with library

Have you encountered this error:  Cannot complete this operation. You cannot remove a document from its owning library. So, whenever we associate a file to a library, a record gets created in each of ContentWorkspaceDoc and ContentDocumentLink objects. If we try to delete any of these records, it throws the error. So, the file or the ContentDocument record itself needs to be deleted to delete the associations. Reference:  https://salesforce.stackexchange.com/questions/317241/delete-a-contentdocumentlink-of-library-file

Salesforce Fact #774 | Check if a file is shared with a library

Image
How to know if a File has been shared with a Library? Once a file is added to a Library, a record is created in the ContentWorkspaceDoc object. We can query this object with the ContentDocumentId to check if a file is shared with a library. Reference:  https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_contentworkspacedoc.htm Attached are the screenshots.

Salesforce Fact #562 | File sharing restriction

Image
There is an option in ContentVersion object to restrict the sharing and unsharing of files. A picklist field named ' Prevent others from sharing and unsharing ' can be set to impose the restriction. The picklist has two values: Freeze Sharing Off, Freeze Sharing On. If  Freeze Sharing On is selected, the file once shared with some users or groups, they cannot share or unshare it further. However, frozen files can still be shared by system admins and file owners, if they have collaborator access to the file. Reference:  https://help.salesforce.com/s/articleView?id=sf.collab_files_freeze_sharing.htm&type=5 https://help.salesforce.com/s/articleView?id=sf.collab_files_freeze_sharing.htm&type=5 Attached are the screenshots.

Salesforce Fact #549 | Default visibility for files

There are different visibility options: InternalUsers, AllUsers related to records.  When there are no communities defined in the org, a File shared with a record will have a default visibility set to AllUsers. When there is at least one community defined in the org, a File shared with a record will have its visibility set to InternalUsers, by default. In order to change the visibility, we need to write a trigger on ContentDocumentLink object. Reference:  https://help.salesforce.com/s/articleView?id=000384243&type=1