6

I referred to this documentation. The description for IsMajorVersion is:

"true if the document is a major version; false if the document is a minor version. Major versions can’t be replaced."

What exactly is implied by "Major versions can’t be replaced"?

I have a file in Salesforce with IsMajorVersion true, inserted by this code:

public static void insertUpdatedDocument(List<ContentDocumentLink> documentLinks, Map<String, Blob> docData)
{
    List<ContentVersion> contentVersions = new List<ContentVersion>();
    for(ContentDocumentLink documentLink : documentLinks) 
    {
        String documentId = documentLink.ContentDocumentId;
        String documentName = documentLink.ContentDocument.title;
        String documentType = documentLink.ContentDocument.FileExtension;
        Blob versionData = docData.get(documentId);
        
        ContentVersion cv = new ContentVersion();
        cv.ContentLocation = 'S';
        cv.ContentDocumentId = documentId;
        cv.VersionData =  versionData;
        cv.Title = documentName+'.'+documentType;
        cv.PathOnClient = cv.Title;
        cv.IsMajorVersion = true;
        cv.OwnerId = Label.Remote_Trx_DocumentOwnerId ;               
        contentVersions.add(cv);
    }
    
    insert contentVersions;
}

But I can upload a new version via the UI:

enter image description here

So what is that field really supposed to prevent?

1
  • I think it is meant to prevent overwrites. It is forcing users to create new version instead of overwriting same version with new content.
    – metasync
    Commented Jun 2, 2022 at 16:48

0

You must log in to answer this question.

Browse other questions tagged .