Site icon UnofficialSF

From Ryan Mercer: Several Great Improvements to File Upload Improved

Ryan Mercer has just brought several improvements to File Upload Improved, which is rapidly becoming full of great capabilities.

Customize the component’s labels.

Require the user to upload at least one file and provide a custom ‘error’ message if they do not.

Automatic icon selection depending on what type of file the user uploads.

Delete the files you’ve uploaded.

Return Content Version Ids and File Names (in addition to the previously returned Content Document Ids) for your use downstream in the flow.

Enable Community Guest Users to Upload Files (Bypassing Community Sharing Rules)

As explained in the File Upload LWC documentation:

“By default, guest users can’t upload files and don’t have access to objects and their associated records.

To enable guest users to upload files, enable the org preference Allow site guest users to upload files. However, even if you enable this setting, guest users can’t upload files to a record unless guest user sharing rules are in place.”

Salesforce provides components a way to publish an optional bypass for the sharing rule restriction, which we have implemented in this release. Setting this input to True activates that bypass. For more information, see Developer Note – Bypass Community Sharing Rules, below

Permission Set

IMPORTANT: This package now installs a permission set named “File Upload Improved”. Make sure to assign it to any community users to whom you want to grant this upload capability.

Developer Note – Bypass Community Sharing Rules

To understand how we implemented the Bypass Community Sharing rules, we encourage you to read the SFDC documentation linked above and to review the new FileUploadImprovedHelper Apex class.

At a high level, we are encrypting the Related Record Id and passing it into the File Upload component via the file-field-name and the file-field-value. onuploadfinished the class is querying the newly created ContentVersions, decrypting the Related Record Id which has been populated in Guest_Record_fileupload__c, and creating ContentDocumentLinks from the uploaded file to the record.

Install

Full Details and Download

Skip to toolbar