I am creating simple interface for posting new Case feed posts (FeedItem objects). These posts are created by admin on behalf of other users (altering the CreatedById field). I'd like to support also adding attachments to these posts. So I am creating ContentVersion object, which ID is then used for the RelatedRecordId of the FeedItem record. It fails:

    "message":"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.",

When comparing properties of my items with those created via SalesForce interface directly, the PublishStatus property of the original ContentVersion object is set to P, while my to R.

This property indicates if and how the document is published. Valid values are:

  • P – The document is published to a public library and is visible to other users.
  • R – The document is published to a personal library and is not visible to other users.
  • U – The document is not published because publishing was interrupted.

Source: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentversion.htm

However, when I try to set this property to P when creating ContentVersion, I am getting another error:

    "message":"Unable to create/update fields: PublishStatus. Please check the security settings of this field and verify that it is read/write for your profile or permission set.",

Our SalesForce technician is unable to find any settings for this.

From various discussions I feel this message is sometimes misleading and it is shown also when such field cannot be set by API at all.

Can I create ContentVersion on behalf of someone else with the PublishStatus property set to P? Or more generaly, can I link an attachment to the FeedItem on behalf of someone else?

  • During further testing I found my solution works for different user. I'll inspect the permission differences between both users and provide an update. – Jan Tosovsky Feb 22 at 15:16

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.