Salesforce Enhanced Notes / ContentNote in Skuid

  • 1
  • Question
  • Updated 3 months ago
  • Answered
Has anyone been able to build a model pulling in Lightning's Enhanced Notes (ContentNote) object? The object shows up as an option when setting up a new Model, and I can pull fields in fine-ish. But what I can't figure out is how to only pull in Note records that meet certain criteria - related to a particular Contact, Account, etc.

Anyone have any luck/experience with this?
Photo of Andrew


  • 102 Points 100 badge 2x thumb

Posted 3 months ago

  • 1
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 16,658 Points 10k badge 2x thumb
I haven’t worked with content notes but looking at the salesforce API notes on it I think I see what you need:
You should see a reference field available for “LastPublishedVersionId”. Drill into that and you should see a field for “FirstPublishedLocationId”. This should be the iD of the record that the not is attached to.
Drilling into that will only give you general field and probably no relationships, so you may need to create a separate model that only returns the target records you want to see content notes for, then condition the content notes model to only show records where FirstPublishedVersionID is in the rows of your other model.
Photo of Andrew


  • 102 Points 100 badge 2x thumb
Ah, that's likely it. I just saw that the "FirstPublishedLocationId" has "135 possible objects". I'll work on trying to get some relationships set up tomorrow.

I'll probably be back for more questions tomorrow when I get to work on it. Thank you!
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 16,658 Points 10k badge 2x thumb
LastPublishedVersion is the Content Version object, I believe. This is important to know, because when you create custom fields on content, you are creating those fields in the content version object. I don’t know if Content Notes allows custom fields, but with regular content you can add custom fields including reference fields. This gives you another option for sorting/filtering/conditioning.
Photo of Rich Slack

Rich Slack

  • 3,988 Points 3k badge 2x thumb
This is what I have been doing and it seems to work: 
1. Create a ContentDocumentLink model

2. Set a condition on the COntentDocumentLink to LinkedEntityID = (either URL parameter id or field from another model).  I used ID field from another model in my example.  This is the parent to the note.

3. Create another model for ContentNote

4. Set a condition on ContentNote for  ContentNote Id IN ContentDocumentLink ContentDocumentID

*Special Note ContentDocumentID is NOT the ContentDocumentLinkID nor is it the LinkedEntityID ie. the parent.  It is the ContentDocumentID i.e. the IDs of the Document or Notes that are linked to the Account.

Here is how I understand it to be working. For the sake of clarity let's say the parent object is Account.  The ContentDocumentLink returns all Documents AND Notes that have been linked to the parent account.  ContentNote then returns Notes where the Note ID was IN the list of Document IDs in the ContentDocumentLink model.  I.E. first model finds all the IDs of both Documents and Notes that are linked to the account.  Model 2  show me all the IDs of NOTES that were in model 1.  Now that I have them all and I know it is a note I can show the title and the text preview, the created date, created by etc.

Bonus Info:
The same thing can be done for Documents.  If you want to return all the documents (i.e. the files that are replacing attachments) you can repeat steps 1 and 2. You can even use the same ContentDocumentLink model since it is returning both Files and Notes Then just:
1.  create a ContentDocument Model

2. Add a condition that the ID field is IN ContentDocumentID from the ContentDocumentLink model. 

That will show you a list of all Files that are linked to the Account/whatever the parent was.

2 Warnings:
1. The ContentDocumentLink is a complex Object.  There are a number of IDs in it. Make sure your models are set up correctly. Here is a screenshot of the fields in the ContentDocumentLink.  HINT you DO need LinkedEntityId and you do need ContentDocumentId. You likely do not need ContentDocumentLinkId

2. You will likely create a table with the ContentNote or the ContentDocument. With Tables, you can LOAD MORE data in by clicking Load More. That is great for that model.  But since your model is grabbing data from the ContentDocumentLink model you may have an issue.  Let's say your ContentDocumentLink is set to only bring in 20 rows.  Your ContentNote is set to bring in 50 rows.  Well, that doesn't really matter because you will be limited by the 20 rows of the ContentDocumentLink. There will be no load more button because your ContentNote model thinks it already got all the records.  SO I leave the ContentDocumentLink set to a very high number or blank. Since it is filtered by records linked to the parent I figure I shouldn't run into an issue.  But that is the problem.  You only have access to load more in from the second model, not from the model that matters.

Sorry if this got long or confusing.  But that is what I have discovered so far. ANd yes, so far this always brings the most recent document or note in.

Oh yeah, and one unfortunate side effect.  With notes you now need to click on the note title and go into the note to edit on the fly.  With the old notes you could edit the body of the note inline on the table so it was much quicker to add notes on the fly.