You need to sign in to do that
Don't have an account?
Phuc Nguyen 18
Share content document link with specific user group or profile
So in this example for inserting Content docuemnt link. How can I limit access to a specifc user group or profile? And how could I use a CMT so that an admin can update or add groups so that the sahring is not hard coded in the apex?
Thanks
Thanks
//Get attachment Attachment attach = [SELECT Id, Name, Body, ContentType, ParentId From Attachment LIMIT 1]; //Insert ContentVersion ContentVersion cVersion = new ContentVersion(); cVersion.ContentLocation = 'S'; cVersion.PathOnClient = attach.Name; cVersion.Origin = 'H'; cVersion.OwnerId = attach.OwnerId; cVersion.Title = attach.Name; cVersion.VersionData = attach.Body; Insert cVersion; //After saved the Content Verison, get the ContentDocumentId Id conDocument = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:cVersion.Id].ContentDocumentId; //Insert ContentDocumentLink ContentDocumentLink cDocLink = new ContentDocumentLink(); cDocLink.ContentDocumentId = conDocument;//Add ContentDocumentId cDocLink.LinkedEntityId = attach.ParentId;//Add attachment parentId cDocLink.ShareType = 'I'; cDocLink.Visibility = 'InternalUsers'; Insert cDocLink;
ContentDocumentLink | Object Reference for Salesforce and Lightning Platform | Salesforce Developers (https://developer.salesforce.com/docs/atlas.en-us.228.0.object_reference.meta/object_reference/sforce_api_objects_contentdocumentlink.htm)
Remember there can be multiple CDLs for a given ContentDocument
regards
Andrew
Can I have something like this:
cDocLink.LinkedEntityId = someGroup.id;
The file needs to be shared with a specifc group/profile and I am also copying the file to another record.
Thanks,
P
The CDL (Content Document Link) is each individual sharing of the Content Document with which ever group.
So ti will be
The ShareType defines what level of Access (e.g. View)
The Visibiloity is who can see.
regards
Andrew