2

I'm trying to let Customer Community users upload and retrieve files on cases. I've done this using Chatter Files before, on a custom object that had it's sharing set to private (because it was a in a master-detail relationship with a private object) without any problems.

The process is as follows: I send the document they want to upload via Javascript Remoting to the Apex controller in pieces. To assemble all the pieces I create a temporary Attachment on the Case. When the file has been completely uploaded, I create a new ContentVersion object, transfer the Attachment body to it along with the filename, and delete the original attachment.

I then insert the ContentVersion object and create a new FeedItem with Type 'ContentPost', ParentId the Id of the case I want to add it to and RelatedRecordId the Id of the ContentVersion I inserted earlier.

However, at the very last step, inserting the FeedItem throws an error saying 'INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY'. I found that turning the FeedItem into a TextPost instead of ContentPost and removing the RelatedRecordId stops this from happening, so I'm assuming the problem isn't with Case permissions. The only other variable is the ContentVersion object, which is owned by the Community User so should technically be completely accessible.

I even tried substituting the case Id for the Id of one of the custom objects I was able to do this with before, and still it doesn't work. Is there anything I'm somehow still overlooking?

EDIT: I've tried enabling Case Feed and Case Feed for Communities, but no change in behaviour. I've also tried creating a CaseFeed Item directly, but its fields are not writable.

  • 1
    Is the ContentVersion.NetworkId field set to the ID of the community when you do the insertion? – alouie Oct 2 '15 at 6:25
  • @alouie It was not, but adding it still gave me the same error – Valyrion Oct 2 '15 at 6:43
1

I haven't found what the reason for the issue was, but I managed to work around it by adding the content of the attachment directly into the FeedItem using the FeedItem.ContentData and FeedItem.ContentFileName fields. It seems that this effectively does the same thing (at least for what I'm doing with the files), so for my use case it's a viable workaround.

| improve this answer | |
  • It seems kind of ridiculous to have to copy the ContentData. In my use case I'm trying to avoid duplicating ContentData. – Scott Morrison Jul 8 '16 at 16:41
0

take A look at the FeedItem doc - NetworkScope and Visibility fields : you should Specifies whether this feed item is available to all users or internal users only.

| improve this answer | |

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.