0

I have 2 child components in a wizard the first on the first page the second on the second page. I pass a recordtype Id from the first component to the second component trough an event how do I pass this to the recordEditForm on Init for the second component. Currently I get an error : expected to get a string for recordTypeId but instead got null

Component

   <lightning:recordEditForm aura:id="form" 
                                  recordId="{!v.recordId}"
                                  objectApiName="{!v.genericObject}"
                                  recordTypeId= "{!v.Id}"  
                                  onsubmit="{!c.next}"
                                  >

Event

 getRecordtypeId: function(component, event, helper) {
        var RecTypeId = event.getParam("Id");
        console.log('The Id is: ' + RecTypeId);
        component.set("v.Id",RecTypeId);
    },
1

You should be using conditional rendering aura:if.

<aura:if isTrue="{!not(empty(v.Id))}">
    <lightning:recordEditForm aura:id="form" 
                                  recordId="{!v.recordId}"
                                  objectApiName="{!v.genericObject}"
                                  recordTypeId= "{!v.Id}"  
                                  onsubmit="{!c.next}"
                                  >
</aura:if>

This will make sure that record form is loaded only when Id is not empty.

Also the content of aura:if is rerendered when ever the condition becomes true. That is, when Id is set.

  • Thanks! So simple but very effective. – Thomas Aug 7 at 12:15

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.