[SalesForce] How to get the Content document Id for file that was just uploaded for a custom object

I have a requirement to allow a user to upload a csv and the system needs to process the file. I am planning to write an apex batch that is scheduled when a file is uploaded. The batch will need to know which file exactly to process. Is there a way to find the content document id of the file that was uploaded using lighting-file-upload ?

Best Answer

I realized I can get it like this

   <lightning-file-upload  record-id={accountId} onuploadfinished = {handleAddressUploadFinised}> </lightning-file-upload>

handleAddressUploadFinised(event) {
            const uploadedFile = event.detail.files[0];
            var documentId  = uploadedFile.documentId;  // this gives the Id for the contentDocument

Related Topic