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) {
//etc
return;
}
}