Git Product home page Git Product logo

sfdc-convert-notes-to-chatter-notes's Introduction

Convert Notes to Enhanced Notes

Overview

In Winter '16 the new enhanced Notes tool became generally available, and with it introduced a new "Notes" related list separate from the classic "Notes & Attachments" related list.

In Spring '17 Salesforce announced that after Winter '18 the "Notes & Attachments" related list will no longer have an upload or attach button. Customers will be required to migrate to and adopt Salesforce Files. Although this change is specific to Attachments/Files, it is very clear that "Notes & Attachments" related list will eventually be retired in favor of the new Files and Notes related lists.

At the time of this project, Salesforce has not (yet?) provided an official conversion tool from Notes to Enhanced Notes.

This project enables the manual or automatic conversion of classic Notes into Enhanced Notes to take advantage of more sophisticated features, like sharing, revisions, rich text, images, etc.

The package includes visualforce pages that let you:

  • Configure sharing and conversion options
  • Run test conversions
  • Enable near real-time or scheduled conversions

Additional Background:

Related Ideas

Pre-Requisites

  • Summer '17 (API 40.0) or later

  • Enable Create Audit Fields so Note create/update/owner fields can be preserved on the new enhanced notes

screen shot

  • Enable New Notes so ContentNote object exists and the new note-taking tool is available

screen shot

Packaged Release History

Release 1.4 (current)

  • Install package
  • Adds support for "Guest Site" users creating notes when the near real-time trigger option is enabled.
  • Adds option to specify "Max Records to Convert" for customers who have more notes to convert than the daily allowed Content Publication Limit. This allows those admins to better plan multi-day conversions. (Issue 1)
  • Updated all code to API v41.0 (Winter '18)

Release 1.3

  • New with Winter '18, private notes are converted and shared to parent record using new File Privacy on Records field. (Issue 21)
  • Fixes issue where empty classic note body appears as <p></p> in converted enhanced note. (Issue 19)

Release 1.2

Please note, this app always preserved the original CreatedDate of the converted note but the LastModifiedDate was always "today" because of how the new Enhanced Note was being shared to the parent record. In my original design I had opted to give you all more options around how the newly converted Enhanced Note gets shared to internal and community users as well as whether users with access to the parent entity inherited read-only or edit access to the file. But those options came at the cost of never being able to preserve the original LastModifiedDate.

Responding to your all's feedback and use cases, this version of the app now preserves the LastModifiedDate of the original note! However, to make this possible means the app no longer manually shares the new Enhanced Note by explicitly creating ContentDocumentLink records. This has the side effect that two previously available conversion settings have now been removed:

  • Which community of users who have access to the note's parent record get access to the converted notes?
  • How should view or edit access to the converted note be granted to users with access to the note's parent record?

These options now rely on the Salesforce defaults.

Release 1.1

Release 1.0

  • Initial release

Installing the Source Code (Developers)

You may install the unmanaged code from GitHub and make any desired adjustments. You are responsible for ensuring unit tests meet your org's validation rules and other requirements.

Getting Started

  1. Enable setting Create Audit Fields so Note create/update/owner fields can be preserved on the new enhanced notes
  2. Enable setting New Notes so ContentNote object exists and the new note-taking tool is available
  3. Add "Notes" related list to your page layouts (e.g. Accounts, Contacts, Tasks, Events, etc.)
  4. Deploy the package using one of the installation links above
  5. Assign yourself the permission set Convert Notes to Enhanced Notes then switch to the app by the same name
  6. On the Convert Notes to Enhanced Notes tab page, click on Setup Conversion Settings to configure sharing and conversion behavior
  7. Perform a test conversion
  8. Consider automating conversion

screen shot

screen shot

FAQ

Salesforce System Errors

Salesforce System Error: 208410828-86802 (1615802660)

Salesforce System Error: 623811003-63707 (123133497)

According to Salesforce documentation,

ContentNote currently provides a generic error like "Note could not be saved." whenever an issue is encountered while parsing the Note file itself. This is often an indication of an issue with the contents of the text body (Content) file, such as special character(s) that have not been properly escaped.

Any conversion errors are reported in the Convert Notes to Enhanced Notes Logs object. If the details reported there are not sufficient for you to resolve the conversion issue then if you trust me share with me the note trying to be converted and I'll see if I can pinpoint if it's due to special characters or encoding.

You may need to manually export your Note records and replace any special characters then update them back into Salesforce prior attempting to convert them. Please see comments made by Rachel Park on this thread in Success Community on 8/23/2017:

"Using Data Loader, I actually exported all of the original Notes and did a find/replace on the special characters in Excel and then updated the records in Salesforce. When I ran the conversion process again afterwards, everything completed fine!"

Regex too complicated

You may encounter this error if your original note is very large or contains a lot of HTML formatting.

If you trust me share with me the note trying to be converted and I'll see if I can pinpoint the cause and provide a fix.

Max Documents or Versions Published Governor Limit

When converting classic Notes & Attachments the new data is stored in the ContentVersion object. There is a limit to how many of these records can be created in a 24 hour period. With Summer '17 release the limit is increased from 36,000 to 200,000! If you have a lot of Notes & Attachments to convert plan around this limit and split the work across multiple days.

Field is not writeable: ContentVersion.CreatedById

When you deploy the package you might get error that files are invalid and need recompilation and one of the specific messages might say "Field is not writeable: ContentVersion.CreatedById". The conversion tool tries to copy the notes's original created and last modified date/user to the converted enhanced note. To do so then the "Create Audit Fields" feature must be enabled. Please see this help article for instructions enable this feature.

screen shot

screen shot

Visibility InternalUsers is not permitted for this linked record.

When the conversion tool shares the enhanced note to the note's owner and parent record the ContentDocumentLink.Visibility field controls which community of users, internal or external, may gain access to the enhanced note if they have access to the related record.

When communities are enabled then both picklist values AllUsers and InternalUsers are acceptable. When communities are disabled then only the picklist value AllUsers is acceptable.

This error usually means communities are disabled in your org and you're trying to set the visibility of the converted enhanced notes to InternalUsers.

To fix then either (a) enable communities or (b) change the visibility option to AllUsers.

INSUFFICIENT_ACCESS_OR_READONLY, Invalid sharing type I: [ShareType]

This error means the object the new file is trying to be shared to does not support the conversion setting Users inherit view or edit access to the file based on their view or edit access to the attachment's parent record and instead you must try Users can only view the file but cannot edit it, even if the user can edit the attachment's parent record.

This is known to occur with Solution object and likely other objects.

FIELD_INTEGRITY_EXCEPTION, Owner ID: id value of incorrect type: 035xxxxxxxxxxxxxxx: [OwnerId]

Prior to Spring '12, Salesfore customers could have Self-Service Portals, which pre-date the modern Communities we have today. This error means the Note is owned by a Self-Service User and ContentVersions cannot be owned by them. You may want to consider changing ownership of those notes to actual user records whose IDs start with 005 prefix.

How are private notes converted?

Starting with Release 1.3 of the app, private notes are converted to enhanced notes and related to the parent record as you would expect and the enhanced note's privacy is preserved by using Winter '18 feature **File Privacy on Records".

Prior to Release 1.3, private notes were handled differently:

Classic Notes & Attachments have an IsPrivate checkbox field that when selected makes the record only visible to the owner and administrators, even through the Note or Attachment is related to the parent entity (e.g. Account or Contact). However, ContentNote object follows a different approach. Rather than an explicit 'IsPrivate' checkbox it uses a robust sharing model, one of the reasons to convert to the new enhanced notes to begin with! In this sharing model, to make a record private then it simpy isn't shared with any other users or records. The caveat then is that these unshared (private) enhanced notes do not show up contextually on any Salesforce record. By sharing the new enhanced note with the original parent record then any user who has visibility to that parent record now has access to this previously private note.

Therefore, when converting you have the option to:

(a) ignore private notes and not convert them

(b) convert and share them with the parent entity

(c) convert them but don't share them with the parent entity, they will reside in the note owner's private library

Inactive Owners

ContentNote records cannot be created and be owned by an inactive user. The enhanced notes must be owned by an active user to be created otherwise get error INACTIVE_OWNER_OR_USER, owner or user is inactive.. Prior to running conversion you should either (a) update all old notes with inactive owners to be owned by an active user, or (b) convert them manually first.

If I run the conversion multiple times, do duplicate enhanced notes get created for the same notes?

No, no duplicate enhanced notes should be created once a note has been converted once. When notes are converted into enhanced notes we store the Note.ID in the ContentVersion.Original_Record_ID__c field for tracking purposes. The conversion logic first checks if there exist any enhanced notes that have been stamped with the note id, if yes then we skip converting that note again.

Of course, if you choose the conversion option to delete the notes upon conversion then no such note would exist the second time around. But if you choose to keep the notes post conversion they will not be converted again if you run conversion process multiple times.

Disclaimer

This is not an official conversion tool by salesforce.com to migrate Notes to Enhanced Notes. This is a personal project by Doug Ayers to assist customers in migrating to and adopting Enhanced Notes. Although this tool has been successfully tested with several customers since 2015 that have between dozens to tens of thousands of notes, please do your own due diligence and testing in a sandbox before ever attempting this in production.

Always make a backup of your data before attempting any data conversion operations.

You may read the project license here.

Special Thanks

sfdc-convert-notes-to-chatter-notes's People

Contributors

douglascayers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sfdc-convert-notes-to-chatter-notes's Issues

New Option: Max Daily Conversion Limit

Since Salesforce enforces a max of 36,000 ContentVersions published in a 24-hour period (can be increased to 50,000 by contacting support), then this poses a problem for orgs with more than 36,000 attachments to convert.

Summer '17 should be increasing the limit to 200,000 which will be a big help, but we still need way to mitigate running into whatever governor limit does exist.

Add new conversion option to limit the max number of attachments the batch job will try to convert in the current day. This will allow admins to throttle how many attachments they convert each day and try to stay under the governor limit.

Inactive owners

HI Doug,

As you have mentioned on your posts I have updated all the inactive owners of the notes to an active owner as a pre step but still am receiving 'This user is inactive' error message.

I was looking at the 'ConvertNotesToContentNotesService' class and noticed below lines(#79,#80) of code where we are setting the owner of the contentNote to be same as whoever has created the Note.

ownerId = note.createdById, // system requirement, owner and creator must be the same
createdById = note.createdById,

In this case should not we change the code to below lines of code?( if we dont then createdByid is still an inactive user as we just updated the owner to be active)

ownerId = note.OwnerId, // system requirement, owner and creator must be the same
createdById = note.OwnerId,

I have updated the code in the class manually myself but am still receiving the same error message. I have also given the user permission to 'Update Records with Inactive Owners'.

I would appreciate if you could please check those two lines of code and let me know if I am missing something.

Test failing - Partner Community

Deployment CompleteTest failure, method: ConvertNotesToContentNotesServiceTest.test_partner_community_users -- System.QueryException: List has no rows for assignment to SObject stack Class.ConvertNotesToContentNotesServiceTest.test_partner_community_users: line 24, column 1

Hello, I'm getting the above error and have tried a number of things to resolve it, but have been unsuccessful. We have a partner community enabled in this org. Is there a quick fix to this problem?

ConvertNotesToContentNotesServiceTest fails if no Partner Community is enabled in the org

The ConvertNotesToContentNotesServiceTest.test_partner_community_users() method fails at line 25 when Communities isn't enabled in an org, because it can't find a Profile with the specified name. Error message is:

List has no rows for assignment to SObject stack Class.ConvertNotesToContentNotesServiceTest.test_partner_community_users: line 25, column 1

Instead of binding to a single sObject instance, it should bind to a collection and inspect if the collection is null, then branch / handle accordingly.

Warn about non ASCII characters

Per John Lee,

Initially, I looked for those characters (¢ © ® ™). In the end, had to look for all non-ASCII characters and either deleted them or converted to some other ASCII character.

This is the regex I used to find all non-ascii characters "[^\x00-\x7f]" (everything in the double quotes) when I was searching in Excel.

The characters ranged from Chinese, non-printable, emoji, bullets, to MS Word smart quote characters.

Try to inspect Note content for non ascii characters that would cause Note conversion to fail and skip it so user knows to review those records. Give option in app to skip notes that may fail or attempt to convert anyways.

Weird behavior on migrating notes

I have just installed the app and triggered the Notes conversion. There are two things that are not clear to me:

  1. I have 709 Notes in my Org and upon submitting the conversion in setup=>monitoring=>apex jobs I see 709 batches but it only gets to 592 and there stops. Status is processing but it never progress from 592. Am I missing something?
  2. This one is realy weird. After I submitted the conversion and Job comes to 592 processed batches, I can see the new Notes in the Notes Related List. If I enter them I can clearly see it is the new one. However, I still don't have any ContentNote in the Org. select count() from contentnote returns 0. Contentnote is the new Note, right?

Thank you in advance
Marko

Been running process for days but now get Salesforce System error

Hi,

I have been using the Notes to Enhanced notes conversion app and been doing 2000 conversions in a 24 hour period including deleting the old note as it goes to the Enhanced notes. Come the batch count left at 100 but it will no longer process. I get the same issue in both Production and Testing sandbox(full).

Error is : Salesforce System Error: 1439474981-49883 (123133497) (123133497)

It will no longer process any batches. I have turned off delete and also sent a batch with 1 record and it takes a while to process and then shows this error.

Any help would be appreciated. Trying to convert the notes by end of month or ASAP.

Thanks

Mike

Try to decipher System Error Codes

When the batch job fails to convert due to:

Note cant be saved because it contains HTML tags or unescaped characters that are not allowed in a Note.

The system generated apex exception email for the managed package only says:

Salesforce System Error: 623811003-63707 (123133497) (123133497)

I'm not sure if this error code always means this reason, but if so perhaps try to capture this error code so a meaningful message can be added to the log record.

Note Not Editable After Conversion

I just created an old note, and used the tool to convert the single ID (Opportunity). It worked perfectly, but I just realized that I can now no longer edit the Enhanced Note. Did I miss something?

Note body is empty

I have found there is an issue when the original note body is empty. The enhanced note is then created with "

" as the new note text. There are some people at our organization that created notes with only the subject.

How to mass pull note ID's?

I have hundreds of notes that I need to convert, how am I supposed to pull the ID of every note in mass without having to go to each individual note to pull it when SF doesn't have the option to report on Notes & Attachments? Thanks!

All notes not getting converted

Hello, Doug Ayers.

I really loved the app. I tried a record or two initially to convert into Notes from Notes and Attachments.
Then, i submitted a request for conversion of notes of around 10k accounts and then i randomly checked the Account IDs to see if all the notes got converted.

I could see only 500 account IDs which have the notes got converted and i don't see any error in the log.

Please guide me on the same.

Ability to report on conversions

As an admin converting notes, I need way to report on conversions to know which notes converted or failed to confirm expected results. Due to nature of Enhanced Note sharing model, only notes explicitly shared with me am I able to query.

Newlines being converted to <br> text

I'm using your excellent tool to auto-convert Notes that are being received via a Slack integration as plain text.
Unfortunately, text that contains newline characters are being converted to
text, and are showing up like that in the new Enhanced Note
eg
Test message
after newline

after two newlines

Comes through in the converted Note as
Test message
after newline

after two newlines

Is there a specific character sequence or character I should insert into the old-style note that will be converted to a true newline in the converted note?
Thx!
iain

Thank you!

Hi Doug,

First, I want to say thank you for all of the hard work that you do!

I am trying to push this into salesforce from github and am getting this error:
Deployment CompleteTest failure, method: DeleteBatchTest.coverageAll -- System.AssertException: Assertion Failed: Expected: 0, Actual: 3 stack Class.DeleteBatchTest.coverageAll: line 29, column 1

Am I doing something to cause this? Thank you again!

Salesforce System Error: 208410828-86802 (1615802660)

Hello Doug,
I am having an issue with conversion and hoping you can help me.
When doing a test conversion (all records, ~26000) in the sandbox, the apex job hangs at one point, stays like that for a couple of hours and then errors out:
Salesforce System Error: 208410828-86802 (1615802660) (1615802660)

I've contacted SFDC support to figure out what this error means and they advised that this is the same error when the note contains HTML or invalid characters.
Unfortunately, no log is created about the problematic record.
Would there be a way to pinpoint what record is causing this problem?
Thank you in advance!
Gabor

Install Failed: Dependent class is invalid and needs recompilation

When I try and install the app into a sandbox environment I get this error:

Dependent class is invalid and needs recompilation: Class
dca_cnvrt_note.ConvertNotesToContentNotesBatchable : Dependent class is invalid and needs recompilation: Class dca_cnvrt_note.ConvertNotesToContentNotesService : Field is not writeable: ContentVersion.CreatedById

Any ideas what I can do to fix it?

I want to track notes conversion in a large org.

Hello!

We are trying to convert classic notes to enhanced notes using your plug in. Which initially worked awesome. But now I am experiencing some issues and I was wonder if you could please help me with that:
Is there a way to track which records have been converted?
We have 2 million notes to be converted. We have been running the tool for several days now (because of SFDC limits) At the beginning we could see the progress (number of batches processed in apex jobs) but now it just stops (and after several hours of inactivity, I get an error: Salesforce System Error: 1956974305-450 (123133497) (123133497))
Also, is there a way to query converted notes? If I open parent records in the UI, I can see the new notes, but if I query ContentNote, I cannot see them.

Any thoughts?
Thanks in advance,
Pam

Cannot see item in log

Hi,
I am successfully able to convert around 94,000 notes. but for remaining 7000 notes i am not able to see them in either "Converted" or "Error" or "Skipped" related list. I am not able to trace why these 7000 notes are not getting converted.

What i have tried:
For debugging, i have supplied 1 note id and then tried running conversion.
Below is the debug log:

screen shot 2017-10-16 at 8 41 44 pm

P.S. this should have nothing to do with salesforce limits as i have already raised the limit by opening a case.

Share Private Notes to Parent Records

In Winter '18, Salesforce introduced new field ContentVersion.SharingPrivacy which mimics the same behavior as Note.IsPrivate.

Request that any private notes be converted and shared to parent record and use the new SharingPrivacy field to preserve privacy.

Reported by Jeff Issenberg

Can't install getting an error

NEVER-MIND: Was installing in the wrong org, it would be great for people that work in many orgs if before you install it displays what org it's trying to install into.

I have gone through the instructions and have enabled notes in settings, and checked off Enable "Set Audit Fields upon Record Creation" and "Update Records with Inactive Owners" User Permissions, I also created a permission set to assign the to me. I am getting this error still.... Any suggestions?
screen shot 2018-01-12 at 12 55 00 pm

Batches are failing

Great tool. Saved me a lot of time with data migration.

It seems successfully process a 1-3 batches and then stop. I have tried batch size of 1 and it processed 4 records. Batch size of 5 and 10 records. There are no triggers or automations.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.