Delete Salesforce ContentVersion

Delete Salesforce ContentVersion

We can use the ContentVersion object/entity to create, query, retrieve, search, edit, and update a specific version of a Salesforce file. We cannot delete it though. We can use the ContentDocument object/entity to retrieve, query, update, and delete the latest version of a Salesforce file.

Delete action/operation is not supported on the ContentVersion object/entity. So, Content Document should be queried and deleted which in turn will delete the Content Versions.

Supported Calls/Actions on ContentVersion object/entity:

create(), describeLayout(), describeSObjects(), query(), retrieve(), search(), update(), upsert()

Reference Article:

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


SOQL to query ContentDocumentId from ContentVersion:

SELECT ContentDocumentId
FROM ContentVersion
WHERE Id IN (
    '068d0000001pvYDAAI',
    '068d0000001pvVTAAG',
    '068d0000001pvVnAAP',
    '068d0000001pblDAAY',
    '068d0000001BFm7AAR'
)

Leave a Reply