2

I'm using lightning:recordForm with recordTYpeId for showing the user a new blank form when they need to input data. This works great since the page layout is controlled by the administrator for the user and record type. However, when I gave that form the record id to let them edit that data, only the Id field is being displayed. I've tried to break up the creation of the attributes in case i need to give the only the record id and not the record type id, but that didnt help. heres what I got

showEditRecordForm : function(component, row_id){
    var component_attributes = {
        "objectApiName" : "Applicant_History__c",
        "layoutType" : "Compact",
        "recordId" : row_id,
        "recordTypeId" : component.get("v.applicant.recordTypeId"),
        "columns" : component.get("v.NewRecordColumns"),
        "mode" : "edit",
        "oncancel" : component.getReference("c.handleCancel"),
        "onload" : component.getReference("c.handleOnLoad"),
        "onsuccess" : component.getReference("c.handleSuccess"),
        "aura:id" : "newForm"
    };
    this.displayModalRecordForm(component, component_attributes);
},
showNewRecordForm : function(component, row_id){

    var component_attributes = {
        "objectApiName" : "Applicant_History__c",
        "layoutType" : "Compact",
        "recordId" : row_id,
        "recordTypeId" : component.get("v.applicant.recordTypeId"),
        "columns" : component.get("v.NewRecordColumns"),
        "mode" : "edit",
        "oncancel" : component.getReference("c.handleCancel"),
        "onload" : component.getReference("c.handleOnLoad"),
        "onsuccess" : component.getReference("c.handleSuccess"),
        "aura:id" : "newForm"

    };
    this.displayModalRecordForm(component, component_attributes);

},
displayModalRecordForm : function(component, attributes){
    var modalBody;
    $A.createComponent(
        "lightning:recordForm",
        attributes,
        function(content, status) {
            if (status === "SUCCESS") {
                modalBody = content;
                var modalPromise = component.find('overlayLib').showCustomModal({
                    header: component.get("v.RelatedListLabel"),
                    body: modalBody, 
                    showCloseButton: true,
                    cssClass: "mymodal",
                    closeCallback: function() {
                        console.log('You closed the modal!');
                        helper.loadData(component);
                        //helper.getData(component);
                    }
                });
                component.set("v.modalPromise", modalPromise);
            }                               
        });
}

this is image of form when passed a record id

When I hit the new button, it looks like this:

0

1 Answer 1

1

Solution found! I changed the layout from Compact to Full, and the fields appeared!

showEditRecordForm : function(component, row_id){
    var component_attributes = {
        "objectApiName" : "Applicant_History__c",
        "recordId" : row_id,
        "recordTypeId" : component.get("v.applicant.recordTypeId"),
        "layoutType" : "Full",
        "columns" : component.get("v.NewRecordColumns"),
        "mode" : "edit",
        "oncancel" : component.getReference("c.handleCancel"),
        "onload" : component.getReference("c.handleOnLoad"),
        "onsuccess" : component.getReference("c.handleSuccess"),
        "aura:id" : "newForm"
    };
    //console.log(component_attributes);
    this.displayModalRecordForm(component, component_attributes);
}
3
  • FYI: Again it will cause error if your fields are not in the page layout. make use of fields attribute in 'lightning:recordForm' to show respective fields.
    – vignesh
    Aug 14, 2018 at 8:02
  • @vignesh i dont have any fields on the page layout and not specifying any fields. when would i see this error? it seems to be working perfectly
    – textual
    Aug 15, 2018 at 3:26
  • Please accept your answer to resolve this question.
    – isherwood
    Oct 15, 2020 at 15:42

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.