Saturday 7 December 2019

Lightning Web Component lightning-file-upload and edit file content


A lightning-file-upload component provides an easy and integrated way for users to upload multiple files. The file uploader includes drag-and-drop functionality and filtering by file types.

to use lightning-file-upload you must have recordId of the record that the uploaded file is associated with, lightning-file-upload component will appear to disable in the absence of recordId.

Below code will upload the images and displays them with onclick functionality which will enable you to edit the title and description of uploaded files with delete functionality.








Points to remember: 
1. Not supported in Lightning Out or standalone apps, and displays as a disabled input.
2. The file uploader cannot be used to upload files with the following file extensions: .htm, .html, .htt, .htx, .mhtm, .mhtml, .shtm, .shtml, .acgi, .svg.
3. lwc file-upload multiple don't work in android, In android you cannot upload multiple files, pls refer this link

Reference: lwc deveoper guide, W3School, Salesforce Ideas

Tuesday 3 December 2019

lightning-input error message using Validity methods


When using lightning-input component, we can use validity methods (setCustomValidity, reportValidity, checkValidity) to display error messages.