Taking notes is great, and taking notes with the Salesforce’s new enhanced note-taking tool is better, but leveraging Salesforce’s new enhanced notes via apex is the best of all!
First things first, the new Notes feature needs to be enabled in your org:
That’s it, Notes are now enabled!
Next, you’ll need to add the Notes related list to the Page Layouts of objects that you’d like it to be able to use with Notes.
Once Notes are enabled, you’ll be able to take great notes from the SF1 app and the Salesforce site.
In SF1, you’ll just open the app, click on the Notes icon, and start typing away. You can then choose Records to relate to the Note, and you’ll even be able to swipe lines in the note to create tasks from the things you’ve jotted down, and then, once you’ve done it, you can mark the task complete right from the Note.
From the browser, in Lightning Experience, you’ll have the Notes icon, but in Salesforce Classic you’ll need to access Notes directly from the Files tab. They’ll function similarly, with a rich text editor for putting your notes in.
Lightning Experience will have a few more features though, such as being able to pop open a new or existing note and editing it without leaving a record, and being able to relate it to other objects right from the note.
That’s it, minimally, that is all that is required to start using Notes, but it seems like more can be done right?
Yes, you’re right, more can be done!
Leveraging Apex, we can do all kinds of things with Notes. Whether you’d like to have Notes created on related records when another record is updated, you’d like every Note that’s made on a parent available to all of it’s children, or you’d like to roll your own Notes component and link a Note to anything you’d like, as long as it’s possible in apex, then the sky is the (apex) limit!
Lets first take a look at the Note object and it’s buddy the Content Document Link object. Each Note has one or many Content Document Links, they act as a link to sObjects. In this way, a Note can be linked to any number of objects. Here’s a visual representation to help you visualize the relationships:
Now that we understand the way Notes, Content Document Links, and Objects are related, with a few simple lines of Apex, we can be off and running creating notes however we want, and linked to whatever we want!
Here’s an example of how to create a Note and a Content Document Link using apex:
That’s the basic’s, pretty simple right! I hope you were taking notes!