3

Im not getting error written on trigger.adderror in files related list in lightning. Trigger.adderror is not working in lightning file related list.

5

It's a known issue. You can find the details here.

Custom error messages not displayed in Lightning Experience when uploading files

Summary:-

Server error messages (added via addError() for instance) are not displayed in various scenarios (e.g. file upload) in Lightning Experience. They are displayed as expected in Classic.

Repro:-

  1. Create an Apex trigger named 'AttachmentTriggerForInsert' on ContentDocumentLink object as following:
 trigger AttachmentTriggerForInsert on ContentDocumentLink (after Insert) { 
    for(ContentDocumentLink obj : Trigger.new){ 
    obj.addError('Test message! You can not upload the file!!!'); 
    } 
    }
  1. Switch to Lightnig Experience if necessary
  2. Go to "Files" tab
  3. Click "Upload Files" button and choose any file to attach.

You will see "Can't upload [Your uploaded file name]." error message instead of seeing 'Test message! You can not upload the file!!!' set in 'AttachmentTriggerForInsert' Apex Trigger. Note this message is below the uploader progress bar.

In Classic, the custom error message is expected.

Workaround

If the org has some record types on ContentVersion, errors will be displayed in the "Add File Details" panel, where the user will see "Enter details on next page", instead of "Can't upload file".

Updates

Multiple file uploads were introduced in Summer '17 (https://releasenotes.docs.salesforce.com/en-us/summer17/release-notes/rn_files_related_list_drag.htm). This functionality is available in the following scenarios:

  1. [Desktop only] Files home
  2. [Desktop only] Files/Notes and Attachments related list
  3. [Desktop and Mobile] lightning:fileUploader component

In these places, the component returns a hard coded error message (i.e. "Can't upload") instead of a custom error message set for instance via addError().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.