2

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,

The Error I got when I click SAVE button

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.

7

From official documentation

Supported Objects

This component doesn't support all Salesforce standard objects. For example, the Event and Task objects are not supported.

For a list of supported objects, see the User Interface API Developer Guide.

and reading Supported Objects article:

User Interface API supports all custom objects and many standard objects.

So answer is: no, lightning:recordForm dosn't support custom settings

  • Yeah correct and got it. Is there any other way to edit a custom settings using predefined lightning component or we need to do this manually? – Hariprasath Sep 18 '18 at 10:27
  • 2
    @Hariprasath as far as I know, the only option for now is to develop such component manually. – Oleksandr Berehovskyi Sep 18 '18 at 10:29

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.