I need to create a lightning component to Edit a particular Custom settings Record using the lightning:recordForm. But I couldn't able to achieve it and got the following error. I will share my code below,
Component:
<aura:component description="EL_Error_Log_Settings">
<aura:attribute name="recordId" type="String" description="The Settings Id" deafult='a073E000005bZ5d'/>
<aura:attribute name="fieldsArray" type="String[]" default="['Error_Log_Activated__c','Error_Log_Include_Executing_User__c','Error_Log_Recipients__c','Error_Log_Send_Notification_Email__c','Error_Log_Storage_Duration__c']"/>
<aura:handler name="init" value="{!this}" action="{!c.handleInit}" />
<lightning:card iconName="custom:custom19" title="Edit lightning:recordForm">
<div class="slds-p-left_large slds-p-right_medium">
<lightning:recordForm aura:id="recordViewForm"
objectApiName="Sample__Settings__c"
columns="2"
fields="{!v.fieldsArray}"
recordId="{!v.recordId}"
mode="Edit"
onsuccess="{!c.onSuccess}"
onsubmit="{!c.onSubmit}"
onload="{!c.onLoad}"
onerror="{!c.onError}"
/>
</div>
</lightning:card>
<soco:EL_Configuration_Service aura:id="ErrorLogService" />
</aura:component>
Controller:
({
handleInit : function(cmp, event, helper){
helper.getSampleSettings(cmp, event, helper);
},
onSuccess : function(component, event, helper) {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Success!",
"message": "The record has been Saved successfully."
});
toastEvent.fire();
},
onSubmit : function(component, event, helper) {
},
onLoad : function(component, event, helper) {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Loaded!",
"message": "The record has been Loaded successfully ."
});
toastEvent.fire();
},
onError : function(component, event, helper) {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Error!",
"message": "Error."
});
toastEvent.fire();
}
})
helper
({
getSampleSettings : function(cmp, event, helper) {
var service = cmp.find("ErrorLogService");
service.getCustomSetting().then($A.getCallback(function(response) {
var responses = response.Error_Log_Activated__c;
alert(responses);
var recordId = response.Id;
alert(recordId);
cmp.set("v.recordId", recordId);
})
);
}
})
Please give any suggestions to overcome this issue.