Skip to main content
added 182 characters in body
Source Link
Valyrion
  • 1.2k
  • 19
  • 45

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.

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?

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.

Source Link
Valyrion
  • 1.2k
  • 19
  • 45

Can't add ContentPost type FeedItems on cases from customer community user

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?