Find your content:

Search form

You are here

Can't we query ContentVersion to get the file posted on the Object?


We have VF page that allows a user to upload an attachment that we later convert to FeedItem. THe VF Page also allows updating the FeedItem by inserting a new ContentVersion.

The whole thing works fine in our dev org. We have created a managed package out of it and installed it to another Enterprise edition org. The same thing however doesn't works in Enterprise edition.

Instead of updating the FeedItem, the code is creating a new Feed. We have also found that query to ContentVersion based is not returning any values.

Can you give an idea what might be causing this issue?

Attribution to: Chirag Mehta

Possible Suggestion/Solution #1

You can query the Contentversion to get the files posted on the Object. But before you can do this, you must make sure the files are shared to your API user or to the company.

This is because the access control of ContentVersion is a little different with others. see doc,

Users (including users with the “View All Data” permission) can only query files they have access to, including:

All Salesforce CRM Content files in libraries they're a member of and in their personal library, regardless of library permissions (API version 17.0 and later).

All Chatter files they own, posted on their profile, posted on groups they can see, and shared directly with them (API version 21.0 and later).

Therefore, even a user with “View All Data” permission and can browse the files in the interface; if the files is not shared to him, he still can't query the files by API.

Attribution to: Jia Hu

Possible Suggestion/Solution #2

I don't think you can update FeedItem, in the documentation, it's not an updatable() object.

That being said, it's interesting that you were able to do it in your 'dev' org unless you were confused. The managed package shouldn't have much to do with the functionality of the code, unless your using a @RemoteAction or some other client-side script that requires a namespace prefix?

Attribution to: jordan.baucke
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content