Have you heard? The Notes & Attachments related list is on the way out. Content Notes and Files will replace these features, and both have major advantages over the “old” notes and attachments. The biggest difference is enhanced sharing for both, and rich text for notes. Read more about (new) Notes and Files here.
You may be saying, Great! I love adding bullet points to my notes! And if you are working in a brand-new instance of Salesforce (with or without the Nonprofit Success Pack), you’re all set. But keep reading this article so that you can help someone else out of the following predicament:
How do I get my old notes to be fancy new Salesforce Content Notes?
Salesforce has a guide! Now, this guide is correct and it works. But before you get too relaxed, take a look at this line: “Each note that you wish to insert should have a corresponding .txt or .html file on your local hard drive that contains the body (Content) of the note itself.”
So, if you have 10,000 notes from an old system or a database you are trying to migrate into your Salesforce instance, you probably have those notes in a csv or excel file. One file with all 10,000 records listed one record per row. Right? So just copy and paste each little note into its own file, click Save As … Wait a minute. That’s not fun.
There are some VBA code options to split an excel file into many if that’s your thing. If you like Unix, there’s a relatively simple code to split one file into many. But once you have all those tiny files in a folder on your computer, there are still so many steps to go through just to get those pesky notes in place!
I did the recommended “create a zillion little files” path once (using Unix to split up an excel sheet) but wondered, “Is there a way to hack use Salesforce to do this for me?” I am used to using data loader to create records from a single CSV file. I thought of Flow, which I can use to create records. I saw Content Notes and Contend Document Links as options in Flow, and I thought “there must be a way…” There is.
Let’s get out all the tools we will need:
- Cloud Flow Designer
- Process Builder
- Microsoft Excel
- Special checkbox field on Activity
Here’s a nutshell version of what we’re going to do, and then I’ll walk through a step-by-step:
Write a flow to create a Content Note based on Task fields: Subject à Title and Description à Content. Launch the flow with a process that checks for an added Task. Next, fork the flow based on whether the task has a WhoID or a WhatID (since they are coming from Notes, it will always be one or the other.) Then the flow creates a Content Document Link record based on the WhoID or WhatID, the ID of the Content Note you just created, and the sharing and visibility choices that are right for you. Finally, delete the Task that started the whole thing – it’s not needed anymore. Import the old notes as Tasks.
If those are enough clues for you, you can skip the rest of the article and go try it 🙂
Step by Step
Back up a sec, Christina, why are you using Tasks? I thought this was about Notes.
We can’t use Process Builder and the old “Notes” records because the old Notes is a weird sort of half-object (not the technical term). BUT what other object has records with something like a Title and Content? You could build a tiny little custom object, but what about using Tasks? Tasks have a Title (Subject) and Content (Comments – API name is Description). Tasks also have a “related to a person field” – called Name by default, its API name is “Who.” Plus, there is another “Related To” field to associate a task with a thing – like an opportunity or case (API name, “What.”) Hmm, Tasks are a lot like the old Notes, huh? But one critical difference here is that you can launch Processes based on Tasks.
Let’s give this a try!
Housekeeping
You need to have Chatter and the new Rich Text Notes feature enabled in your instance. See this help article for more details. You should also plan to do the migration outside of business hours, or try to do it when your users aren’t working in Salesforce. It might all be fine, but this is a good practice.
Step 1. Export “Old” Notes
Export “old” notes using Data Loader. Go ahead and export all the fields. Although we will only use Title and Body for importing into the Tasks and turning into Content Notes, we also want the Parent ID and the “IsPrivate” field might inform your decisions about Sharing and Visibility.
Step 2. Escape the characters!
It’s weird but true – even though Content Notes offer rich text, they will not accept your apostrophes, quotation marks, ampersands, less than, or greater than signs. Best to just accept this. From the Salesforce instructional article mentioned earlier, we have this chart:
You could write some code for this, but it also possible to buckle down for a couple minutes and run find-and-replace in Excel five times. Be sure to run this across both the Title and the Body columns.
Step 3. Let’s talk about the Parents
Still working in Excel, it’s time to sort out which of your Notes are associated with people, and which are associated with things. This is where the ParentID column comes in. All Salesforce record IDs tell you what object they are from via the first three characters. See this handy cheat sheet to learn more about this, but for this exercise, we only need to know one: the ID Prefix for Contacts: 003. In Excel, you can use the LEFT expression to pull out just the first three characters from the ParentID column.
Now, create another couple columns for WhoID and WhatID. Pull the ParentID into the WhoID column if the prefix is 003 and into the WhatID otherwise.
Step 4. Adorable Little Checkbox
Add a checkbox on the Task/Activity object (in Activity Custom Fields). The checkbox does not need to be on the page layout, and you should feel free to delete it when you’re done with the import of Notes à Content Notes. I named mine “CreateContentNote,” but you can name it anything you like.
(Note: It’s possible to skip this and just configure the Process Builder to run every time a task is added, but then you REALLY need to make sure you’re doing this while no one else is working in your system and turn it off when you’re done. For safety’s sake and the option to leave everything in place for possible re-use later, I like the checkbox.)
Step 5. Checkbox-Checker-Offer Column
While you’re thinking of it, add a checkbox-checker-offer column to the export spreadsheet with your notes. Name it the same as your checkbox, and copy TRUE all the way down.
Step 6. Flow!
Time to build your flow. How exciting! Start with a fast lookup of the Task record (you will feed each Task in through Process Builder). You need the following fields:
- Subject
- Description
- WhoID
- WhatID
Next step in the flow, create a Content Note record. Title = Subject and Content = Description from the Task you just looked up. Be sure to assign the new Content Note a VariableID because you’ll need it in an upcoming step.
Now we make our one and only decision in this little flow. Does it have a WhoID (i.e., is this Note related to a person?) or a WhatID (related to an Account, Opportunity, etc.)? It will always have one or the other since these Tasks are coming from Notes. You just need to fill in one path, so I chose “WhoID is not blank” as one outcome; the logical default will be that the Task has a WhatID.
Next, it’s time to create a Content Document Link record. There are going to be two options for this step – one where the WhoID from the specialized Tasks you will import becomes the new ParentID and one where it’s the WhatID that becomes the new ParentID. Only it’s not a ParentID anymore – it’s a LinkedEntityID. A big part of the magic of new Content Notes is that they can be shared more broadly, and connected to multiple entities. But let’s start with just one…
This little Content Document Link record doesn’t have many fields – and the focus for this exercise is the ID of the Content Note you just created and the ID of the Linked Entity (previously: ParentID). But there are a couple more fields you need to populate: ShareType and Visibility.
You can read more about these here to choose which options are right for you. For my use case, I was able to go with I = Inferred permission for ShareType, and AllUsers for Visibility for all records.
Last step in the flow: delete that original Task record. We don’t want them taking up space and potentially confusing people.
Once your flow is complete, you can test is with a test Task and the assignment function in Flow. Now that you know it’s working properly, activate the flow. (Process Builder will only pick up active flows.)
Step 7. Process Builder
Process Builder can be used to check for certain conditions/additions and autolaunch a flow. That’s exactly what we need here. Set up Process Builder to launch that flow you just built when a Task is added with the CreateContentNote checkbox checked. Activate, and that’s it Process Builder, thank you!
Step 8. Import!
Finally, you’re ready to import those old Notes as new, special, temporary Tasks. The fields you need to import – these should now be columns in your Excel sheet – are:
- Title to Subject
- Body to Description
- WhoID to WhoID
- WhatID to WhatID
- CreateContentNote to CreateContentNote (whatever you named your checkbox)
Set your batch size to 1 and run a test import to make sure it’s all working. Then you’re off and running, creating Content Notes from old Notes via a slight hack of Tasks, and without having to click “SaveAs…” 10,000 times. If you’d like more information on this or other techniques for making the most of Salesforce for your organization, please contact Cloud for Good.
You may also be interested in reading: