Lightning Experience Notes: trigger addError method on contentVersion / contentDocument doesn’t display the custom error message for Enhance Notes
Last updated 2019-09-07 ·Reference W-5994486 ·Reported By 4 users
Summary
If you are using addError method to display custom error message in trigger on contentVersion / contentDocument, the custom error from trigger shown in classic but not in Lightning Experience enhanced note-taking tool.
Repro
1. Setup > Notes Setting > Enable notes: true
2. Write below trigger on ContentVersion [A]
3. Add Notes layout on detail page: say ‘Account’ page layout
4. Go to ‘Account’ Detail page
5. Create a new note using the Enhanced note tool and try to edit it after it gets saved.
-------------------------------
[A]Trigger code:-
trigger ContentVersionTrigger on ContentVersion (before update) {
for(ContentVersion ver : trigger.New){
system.debug('#CurrentVersion: '+ Integer.valueOf(ver.VersionNumber));
if(ver.FileType == 'SNOTE' && Integer.valueOf(ver.VersionNumber) > 1) ver.addError('You cannot edit existing notes..==1');
}
}
----------------------------------
#Actual behavior: On Enhance Note update via Enhanced Note tool.
In classic: It displays an alert on Custom error message ‘You cannot edit existing notes…’ added in trigger logic. [working as expected ]
In Lightning: It displays an error in Enhanced Note tool "Review the errors on this page. “Note can't be saved" <standard error message not the addError(<message>) from trigger >
---------------------------------
#Expected behavior:
In Classic: Custom error message ‘You cannot edit existing notes…’ shown as criteria met.
In lightning: Custom error message should be shown as criteria met for fileType='SNOTE' as well.
Workaround
No workaround, standard error message "Note can't be saved" will be shown.
As of now you can use addError method in trigger to handle validations however in LEX error message will be standard error message “ Note can't be saved” for file type SNOTE
Reported By (4)
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.