0

We are getting following error when we try to insert contentdocumentlink to the account using guest user.

Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_OR_READONLY, You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.: []

        ContentVersion cv = new ContentVersion();
        cv.ContentLocation = 'S';
        cv.ContentDocumentId = null;
        cv.VersionData = EncodingUtil.base64Decode(attachments[0].base64Data);
        cv.Title = attachments[0].fileName;
        cv.PathOnClient = attachments[0].filename;

        insert cv;
        system.debug('---->' + cv.id);

        String ContentDocumentId = [SELECT Id, ContentDocumentId FROM ContentVersion WHERE Id =: cv.Id].ContentDocumentId;

        system.debug('---->' + ContentDocumentId);

        ContentDocumentLink cdl = new ContentDocumentLink();
        cdl.ContentDocumentId =ContentDocumentId;
        cdl.LinkedEntityId = accountid;
        cdl.ShareType = 'V';
        cdl.Visibility  = 'AllUsers';
        insert cdl;

Can someone suggest me what is the process to enable content document link for the guest user.

We dont have any triggers written on this. I am able to access account

Thanks Himanshu

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.