2

I am trying to create a dynamic component and i am able to load "loadingSWQuotes" component successfully. I want to pass the quoteid as a parameter to the component.

init : function(component, event, helper) {
        var modalBody;
        var modalFooter;
        var quoteid = event.currentTarget.dataset.id;
        alert(quoteid);
        component.set("v.Quote_id", quoteid);
        $A.createComponents([
            ["c:loadingSWQuotes",{
                    "aura:recordId": quoteid
                }]
        ],
         function(components, status){
             if (status === "SUCCESS") {
                 modalBody = components[0];
                 component.find('overlayLib').showCustomModal({
                     header: "Quotes",
                     body: modalBody,
                     footer: modalFooter,
                     showCloseButton: true,
                     cssClass: "my-modal,my-custom-class,my-other-class",
                     closeCallback: function() {
                     }
                 });
             }
         });
    }

Component I have hard coded the record id in the component now. I want to pass it dynamically

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction"
                access="global" controller="FilesController">
    <!--<aura:attribute name="recordId" type="String"/>-->
    <aura:attribute name="filesIds" type="list"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="recordId" type="string" default="a0902000000IFmjAAG"/>

    <lightning:recordViewForm recordId="a0902000000IFmjAAG" objectApiName="Opportunity_Quotes__c" >
    
    <!--<lightning:recordEditForm objectApiName="Opportunity_Quotes__c" onsuccess="{!c.handleSuccess}">-->
        <lightning:messages />
         <lightning:outputField fieldName="QuoteId__c" />
         <lightning:outputField fieldName="Status__c" />
         <lightning:outputField fieldName="CurrMembers__c" />
         <lightning:outputField fieldName="FinalIncrease__c" />
         <lightning:outputField fieldName="FinalRev__c" />       
    </lightning:recordViewForm>
</aura:component>

1 Answer 1

2

You have used aura:recordId, instead of that use only recordId

For passing values from your parent component you can use :

$A.createComponent(
    "c:ComponentName",
    {
        "acc": "acc"
    },
    function(newComp) {
        var content = component.find("body");
        content.set("v.body", newComp);
    }
);

And define attribute in your created component to access it:

<aura:attribute name="acc" type="Account"/>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .