0

Am trying to publish the uploading file into another library with linked enitity id of normal public group. Here is the trigger code:

    trigger publishContentToAnotherLib on ContentDocumentLink (After insert) {
    for (ContentDocumentLink cdl : trigger.new) {
        String docId = cdl.ContentDocumentId;

        ContentDocumentLink cdl = new ContentDocumentLink();
        cdl.ContentDocumentId = docId;
        //hard coding the normal public group
        cdl.LinkedEntityId = Id.valueOf('00G3F000000YuFe'); // workspaceId where user wants to publish the file.
        cdl.ShareType = 'V';
        cdl.Visibility = 'AllUsers'; 
        insert(cdl);
    }

}

Whenever I upload a file am getting below error:

First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Linked Entity ID: id value of incorrect type: 00G3F000000YuFeUE0: [LinkedEntityId]:

Is there anything I need to make change in the group?

0

The LinkedEntityId needs to be a CollaborationGroup (i.e. Chatter Group, key prefix 0F9), not a public group (key prefix 00G)

From the ContentDocumentLink Object doc

In API versions 33.0 and later, you can create and delete ContentDocumentLink objects with a LinkedEntityId of any record type that can be tracked in the feed, even if feed tracking is disabled for that record type.

In API versions 25.0 and later, you can create ContentDocumentLink objects with a LinkedEntityId of type User, CollaborationGroup, or Organization

There's no Chatter UI to track feeds on public groups but there is a UI to track on Chatter Groups.

  • @user7100889 - see above – cropredy Oct 31 '18 at 4:09

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.