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:

  • Did you check the FLS for the fields for admin profile ? – Mohith Shrivastava Aug 13 '18 at 23:13
  • @MohithShrivastava both my user profile and the community user profile that will be filling out the form have full rights to read and edit. I'm not giving the form the fields, I'm hoping the recordForm will do that automatically – textual Aug 13 '18 at 23:20
  • How does your component look like? Is it in the edit mode? – Jayant Das Aug 13 '18 at 23:57
  • @JayantDas I added a screen shot of the form when theres no record id, it shows all the fields based on record type and page layout correctly. I'm using edit mode for both paths, only the record id is different for the two entry paths – textual Aug 14 '18 at 0:04
  • Can you also please post your component's minimum viable code? – Jayant Das Aug 14 '18 at 0:07
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);
}
  • 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 '18 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 '18 at 3:26

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.