TLDR: How do I retrieve a ContentVersion Object by customfield (jsforce or SOQL) and then how would I then populate that customfield?

More below:

I need a way to keep track of notes between two systems. I do not seem able to add a custom field to notes. I thought of noteTags except, each note will have a separate ID and 10,000+ noteTags doesn't seem to be a good idea.

Then, the option from a colleague was to add a custom field to the content version of a note.

Pardon my iterations, but I am working on this concurrent to this question being "abroad".

If I create a new note with JSforce, I then get a return value of that new notes ID & URL. Just fine. I can then get that notes most current ContentVersion Object. Then I need to add content a custom field to that ContentVersion object... Along the lines of this path:

// Conn = Connection to salesforce, objHandle is the Salesforce Record ID, noteContent is the content of the record, noteTitle is the title of the record.
  async function getSalesForceObject(conn, objHandle, noteContent, noteTitle) {
    try {
      await conn.sobject("ContentNote").create({ Content : noteContent, Title: noteTitle })
        .then((result) => {
          conn.sobject("ContentDocumentLink").create({ ContentDocumentId : result.id, LinkedEntityId: objHandle, ShareType: "V" }, function(err, ret) {
            if (err || !ret.success) { return console.error(err, ret); }
            console.log("Created Linked record id : " + ret.id);
    } catch(err) {
  • 1
    Have you checked the documentation? Aug 30, 2022 at 4:44
  • Sure David. I would say: is one. Another not particular explicit syntax. Possibly I'll sort through it before an answer comes, but I appreciate the comment.
    – Rogelio
    Aug 30, 2022 at 4:49
  • I've been struggling quite mightily though to be honest.
    – Rogelio
    Aug 30, 2022 at 4:56

1 Answer 1


In Salesforce the ContentNote Objects looks as in the below ERD diagram. ContentNote and ContentVersion are related with Id-ContentDocumentId as mentiond in the picture.

enter image description here

To update a CustomField in the ContentVersion you can follow the below steps.

1 - Get the Id of the ContentVersion with the help of ContentNote Id.

SELECT Id FROM ContentVersion WHERE ContentDocumentId = '<Id of ContentNote>'

2 - Now update the ContentVersion with the CustomField Value. The below snippet is from jsforce documentation.

// Single record update (Documentation)
  Id : '<ContentVersion Id from the previous step>',
  CustomField__c : '<Value of the CustomField>'
}, function(err, ret) {
  if (err || !ret.success) { return console.error(err, ret); }
  console.log('Updated Successfully : ' + ret.id);
  // ...

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.