I have some Apex code that inserts a ContentNote and the corresponding ContentDocumentLink. This works fine and the data can be viewed through the normal Salesforce UI.

But some further code that updates the content (in a separate transaction) fails with this DmlException:

Unable to create/update fields: VersionData. Please check the security settings of this field and verify that it is read/write for your profile or permission set.

Now VersionData is a field in the underlying ContentVersion object and the Content objects are not surfaced (as far as I can see) in profiles. So I presume this is being caused by something else.

I'm inserting the ContentDocumentLink with these settings:

    cdl.put('ShareType', 'I');
    cdl.put('Visibility', 'AllUsers');

Any idea how to stop this error from happening?

  • 1
    It occurs to me that this might be a leaky abstraction problem as ContentNote acts as a facade over ContentDocument/ContentDocumentVersion. Not sure of the solution though.
    – Keith C
    Aug 1, 2018 at 7:19

1 Answer 1


Having found this ConvertNotesToContentNotesService class - thanks for posting that code Doug Ayers - I realised that there is a Blob field on the ContentVersion object after all that I had overlooked because it is called "VersionData" not "Content"...

So instead of updating ContentNote, I am now successfully inserting a ContentVersion object created like this:

private static SObject createContentVersion(SObject cn) {

    SObject cnv = ContentNotes.versionType.newSObject();

    cnv.put('ContentDocumentId', cn.Id);
    cnv.put('Title', cn.get('Title'));
    cnv.put('VersionData', cn.get('Content'));

    // This chosen based on inspection of a note created through standard UI
    cnv.put('PathOnClient', cn.get('Title') + '.snote');

    return cnv;

You must log in to answer this question.

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