function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Radha Rathinavel 1Radha Rathinavel 1 

update visiblity column in ContentDocument link

Hi
I tried to update the visibility column in content documnet link object. It throws error.

Error:
System.SObjectException: Field is not writeable: ContentDocumentLink.Visibility

My Code:
List<ContentDocumentLink> cdl1 = new List<ContentDocumentLink>();
List<ContentDocumentLink> cdl =
    [select Id, Visibility, contentdocumentid
     from contentdocumentlink where
     contentdocumentid = '069350000009lvHAAQ'
     ];

for(ContentDocumentLink cd : cdl)
{
    cd.Visibility = 'AllUsers';
    cdl1.add(cd);
}

Update cdl1;