0

I am writing a query to upload the contentversions which are not present in my Organization. For this, I am checking the presence of contentversion if it exists or not. This hit a snag where the query:

SELECT ID FROM CONTENTVERSION WHERE ID IN ('068c0000000FYd5AAL')

fails with 'Invalid parameter value' if this particular Id is not present. If it is present, the corresponding Id is returned. A strange behaviour is that if an Id is not present in the list of Ids, the error is returned.

I wouldn't want to test by running query against every id on my side as it would be a waste of API Calls. Is there a way that I can make it certain that the ContentVersion that is being uploaded doesn't exist already?

7
  • can not offer anything other then trying short id format or trying to access the object by id in browser /068c0000000FYd5AAL, which could give some more details why the id is considered invalid.
    – Pavlonator
    Commented Oct 28, 2016 at 19:22
  • Thanks. But the program written is on the backend and resides on API calls. Besides, it is obvious that I cannot check whether this Id is present in the org individually for the above mentioned reason.
    – dmachop
    Commented Oct 28, 2016 at 19:28
  • Why not upsert?
    – Adrian Larson
    Commented Oct 28, 2016 at 21:10
  • I'm puzzled by the requirement -- one ContentDocument has multiple ContentVersions. What is the starting condition in the database versus the input data set?
    – cropredy
    Commented Oct 29, 2016 at 1:07
  • 1
    @AdrianLarson Upsert caused issue while some items were in recycle bin. In addition to this, upserting all the fields were of an issue. For example, some fields are updateable, createable, etc. If it is either one, I have to include the relevant fields. Using upsert on a field that is createable or updateable only threw errors.Hence this tortuous method of querying the ids.
    – dmachop
    Commented Oct 29, 2016 at 16:48

0

You must log in to answer this question.

Browse other questions tagged .