You need to sign in to do that
Don't have an account?

lightning:fileUpload Error: The lightning fileUpload is showing an error while trying to upload the file and saying Can't upload the file.
Hi all,
I am trying to use lightning:fileUpload in my lightning page and I am getting an error saying can't upload while uploading the file..
Component:
<aura:component implements="force:lightningQuickAction,flexipage:availableForAllPageTypes" access = "global">
<aura:attribute name="displayedSection" type="string" default=""/>
<aura:attribute name="accept" type="List" default="['.jpg', '.jpeg']"/>
<aura:attribute name="multiple" type="Boolean" default="true"/>
<aura:attribute name="disabled" type="Boolean" default="false"/>
<br></br>
<br></br>
<br></br>
<aura:attribute name="options" type="List" default="[
{'label': 'Cash Claim', 'value': '0127F000000EPoKQAW'},
{'label': 'Cell Phone Claim', 'value': '0127F000000EPoUQAW'},
{'label': 'Broadband Claim', 'value': '0127F000000EPoPQAW'},
{'label': 'Petrol & Driver Claim Phone', 'value': '0127F000000EPoZQAW'}]"/>
<aura:attribute name="value" type="String"/>
<div class="slds-box">
<div aura:id="firstsection" class="{!if(v.displayedSection == '','slds-show','slds-hide')}">
<lightning:radioGroup name="radioGroup"
label="Claim Record Type"
options="{! v.options }"
value="{! v.value }"
type="radio"
onclick= "{!c.displaySection2}"/>
</div>
<br><br>
</br></br>
<div aura:id="secondsection" class="{!if(v.displayedSection == 'secondsection','slds-show','slds-hide')}">
<lightning:recordEditForm aura:id="recordViewForm" recordTypeId="{!v.value}" objectApiName="Claim_Request__c">
<lightning:messages />
<lightning:inputField fieldName="Claim_Amount__c" required = "true" />
<lightning:inputField fieldName="Claim_Month__c" required = "true" />
<lightning:inputField fieldName="Claim_Year__c" required = "true"/>
<lightning:inputField fieldName="Description__c" />
<lightning:inputField fieldName="Phone_Number__c" default = "In case of cell phone claim"/>
<lightning:inputField fieldName="Broadband_Number__c" default = "In case of broadband claim" />
<lightning:button aura:id="submit" type="submit" label="Create Claim" class="slds-m-top_medium" onclick = "{!c.showSuccessToast}" />
</lightning:recordEditForm>
<lightning:fileUpload label="Add attachment" multiple="{!v.multiple}"
accept="{!v.accept}" recordId="{!v.value}"
onuploadfinished="{!c.handleUploadFinished}" />
</div>
</div>
</aura:component>
controller:
({
displaySection1 : function(component, event, helper) {
component.set("v.displayedSection","firstsection");
var action = component.find("v.value");
},
displaySection2 : function(component, event, helper) {
var action = component.get("v.value");
//action.setParams({
// "ID": component.get("v.recordId")
//})
//component.find("firstsection");
///component.set("v.displayedSection","section1");
component.set("v.displayedSection","secondsection");
console.log("Claim Request has been submitted");
},
handleUploadFinished : function(component, event, helper) {
var uploadedFiles = event.getParam("files");
var documentId = uploadedFiles[0].documentId;
var fileName = uploadedFiles[0].name;
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Success!",
"message": "File "+fileName+" Uploaded successfully."
});
toastEvent.fire();
$A.get('e.lightning:openFiles').fire({
recordIds: [documentId]
});
},
showSuccessToast : function(component,event,helper)
{
var newClaimRequest = {'objectApiName' : 'claim_request__c',
'claim_amount__c' : '',
'claim_month__c' : '',
'claim_year__c' : '',
'claim_description__c' : '',
'Phone_Number__c' : '',
'Broadband_Number__c' : ''
};
//resetting the Values in the form
component.set("v.recordViewForm",newClaimRequest);
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Success!",
"message": "claim request has been successfully submitted"
});
toastEvent.fire();
}
});
please help, tried a lot and not able to identify what's missing.
I am trying to use lightning:fileUpload in my lightning page and I am getting an error saying can't upload while uploading the file..
Component:
<aura:component implements="force:lightningQuickAction,flexipage:availableForAllPageTypes" access = "global">
<aura:attribute name="displayedSection" type="string" default=""/>
<aura:attribute name="accept" type="List" default="['.jpg', '.jpeg']"/>
<aura:attribute name="multiple" type="Boolean" default="true"/>
<aura:attribute name="disabled" type="Boolean" default="false"/>
<br></br>
<br></br>
<br></br>
<aura:attribute name="options" type="List" default="[
{'label': 'Cash Claim', 'value': '0127F000000EPoKQAW'},
{'label': 'Cell Phone Claim', 'value': '0127F000000EPoUQAW'},
{'label': 'Broadband Claim', 'value': '0127F000000EPoPQAW'},
{'label': 'Petrol & Driver Claim Phone', 'value': '0127F000000EPoZQAW'}]"/>
<aura:attribute name="value" type="String"/>
<div class="slds-box">
<div aura:id="firstsection" class="{!if(v.displayedSection == '','slds-show','slds-hide')}">
<lightning:radioGroup name="radioGroup"
label="Claim Record Type"
options="{! v.options }"
value="{! v.value }"
type="radio"
onclick= "{!c.displaySection2}"/>
</div>
<br><br>
</br></br>
<div aura:id="secondsection" class="{!if(v.displayedSection == 'secondsection','slds-show','slds-hide')}">
<lightning:recordEditForm aura:id="recordViewForm" recordTypeId="{!v.value}" objectApiName="Claim_Request__c">
<lightning:messages />
<lightning:inputField fieldName="Claim_Amount__c" required = "true" />
<lightning:inputField fieldName="Claim_Month__c" required = "true" />
<lightning:inputField fieldName="Claim_Year__c" required = "true"/>
<lightning:inputField fieldName="Description__c" />
<lightning:inputField fieldName="Phone_Number__c" default = "In case of cell phone claim"/>
<lightning:inputField fieldName="Broadband_Number__c" default = "In case of broadband claim" />
<lightning:button aura:id="submit" type="submit" label="Create Claim" class="slds-m-top_medium" onclick = "{!c.showSuccessToast}" />
</lightning:recordEditForm>
<lightning:fileUpload label="Add attachment" multiple="{!v.multiple}"
accept="{!v.accept}" recordId="{!v.value}"
onuploadfinished="{!c.handleUploadFinished}" />
</div>
</div>
</aura:component>
controller:
({
displaySection1 : function(component, event, helper) {
component.set("v.displayedSection","firstsection");
var action = component.find("v.value");
},
displaySection2 : function(component, event, helper) {
var action = component.get("v.value");
//action.setParams({
// "ID": component.get("v.recordId")
//})
//component.find("firstsection");
///component.set("v.displayedSection","section1");
component.set("v.displayedSection","secondsection");
console.log("Claim Request has been submitted");
},
handleUploadFinished : function(component, event, helper) {
var uploadedFiles = event.getParam("files");
var documentId = uploadedFiles[0].documentId;
var fileName = uploadedFiles[0].name;
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Success!",
"message": "File "+fileName+" Uploaded successfully."
});
toastEvent.fire();
$A.get('e.lightning:openFiles').fire({
recordIds: [documentId]
});
},
showSuccessToast : function(component,event,helper)
{
var newClaimRequest = {'objectApiName' : 'claim_request__c',
'claim_amount__c' : '',
'claim_month__c' : '',
'claim_year__c' : '',
'claim_description__c' : '',
'Phone_Number__c' : '',
'Broadband_Number__c' : ''
};
//resetting the Values in the form
component.set("v.recordViewForm",newClaimRequest);
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Success!",
"message": "claim request has been successfully submitted"
});
toastEvent.fire();
}
});
please help, tried a lot and not able to identify what's missing.
I trust you are doing very well.
I have tried the same piece of code in my org and it is working fine for me. Please refer to the below link with a similar discussion which might help you further with the above issue.
https://salesforce.stackexchange.com/questions/215244/upload-a-file-using-lightningfileupload-from-a-customer-community-user-licens
https://success.salesforce.com/issues_view?id=a1p3A0000001CdCQAU&title=can-t-upload-a-file
https://help.salesforce.com/articleView?id=Can-t-upload-or-Can-t-add-1-file-to-when-uploading-a-File&language=en_US&type=1
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.
Thanks and Regards,
Khan Anas
I have already followed these links and I have tried it again but the problem persists. I have already assigned the default record type and validation rules are no longer active.
Can you please share the code you have executed in your org and can you please share the same code and screenshots of the pages to me.
It will be a great help to me.
Thanks & Regards,
Akash
Below is the sample code for fileUpload which I have tested in my org and it is working fine.
Component:
Controller:
Action:
Page Layout:
Screenshot:
1.
2.
3.
I hope it helps you.
Regards,
Khan Anas
This is working fine if I am integrating it with a particular object and using it on a page layout but I want to create a lightning page and I have used it in the home page and here it is still showing me the same error and does it require any additional permission in profile or permisson set???
I am using a developer account.
Please help!!!
Regards,
Akash