0

I'm using a simple lightning component to upload a file to a record.

I would like for the file to uploaded with a certain custom field set. (ie. on upload, set "File Status" to "Signed" - this would be a custom field within the Files object)

Is this possible? And if so, is it a tall task? I'm only moderately experiened with apex.

Would it be just a line or two I could pop into the existing code?

Component:

   <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >

    <aura:attribute name="recordId" type="Id" description="Record to which the files should be attached" />
            <lightning:fileUpload label="Add attachment"           multiple="true"          accept=".pdf, .png, .docx, .xlsx"          recordId="{!v.recordId}"            onuploadfinished="{!c.handleUploadFinished}"           />

</aura:component>

Controller:

({
    handleUploadFinished : function(component, event, helper) {

        // Get the list of uploaded files
        var uploadedFiles = event.getParam("files");

         var toastEvent = $A.get("e.force:showToast");
    toastEvent.setParams({
        "title": "Success!",
        "message": "File "+uploadedFiles[0].name+" Uploaded successfully."
    });
    toastEvent.fire();

    }
})

Your Answer

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

Browse other questions tagged or ask your own question.