2

In the following test method:

    static testMethod void testEmailWithAttachments() {
        ContentVersion contentVersion = new ContentVersion();
        contentVersion.FileType = 'Text';
        contentVersion.VersionData = Blob.valueOf('Some Text');
        contentVersion.Title = 'Test';
        insert contentVersion;
    }

I receive:

Field is not writeable: ContentVersion.FileType

Please advise how to avoid Field is not writeable: ContentVersion.FileType and make the insert in my test method?

1 Answer 1

6

FileType isn't writeable, but PathOnClient is - it's createable, but not updateable. The system will infer the type of file from the pathname extension you supply in that field. (ContentNote records will have type SNOTE; they don't have extensions).

See the SOAP Reference:

FileType is defined by either ContentUrl for links or PathOnClient for documents, but not both.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .