1

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?

3

FileType isn't writeable, but PathOnClient is. 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.