You need to sign in to do that
Don't have an account?
Robert Gallahue
Unable to pass attribute from Parent component to Child component
I am struggling to pass a attribute value from a parent component (Lookupclean) to a child component (flowFooter). I am trying to pass the value to the child component in order to validate that a value has been entered in a field. The parent component is a lookup field (necessary with flow) and the child component is a footer bar. The idea is that the next button wont fire unless a value is entered. However i can not seem to pass the value from Parent to Child.
Parent Component (LookupClean):
Component
Child Component
here is a screenshot showing the two console logs on my Lookupclean after the field is filled
Here is a screenshot showing the two additional console.logs when i press my flowFooter button. the attribute is undefined
Any ideas?
Parent Component (LookupClean):
Component
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:availableForFlowScreens"> <aura:attribute name="object" type="String" default="Offers__c" access="public"></aura:attribute> <aura:attribute name="lookupField" type="String" default="Opportunity__c" access="public"></aura:attribute> <aura:attribute name="selectedRecordId" type="String" access="public"></aura:attribute> <aura:attribute name="parentAttribute" type="String" default='test'></aura:attribute> <c:flowFooter childAttribute="{!v.parentAttribute}"/> <lightning:recordEditForm objectApiName="{! v.object }"> <lightning:inputField fieldName="{! v.lookupField }" aura:id="field" onchange="{! c.handleOnChange }"/> </lightning:recordEditForm> </aura:component>Controller
({ handleOnChange : function(component, event, helper) { component.set( "v.selectedRecordId", event.getParams( "fields" ).value ); var ally = component.find("field").get("v.value"); console.log(ally); component.set("v.parentAttribute",ally); console.log(component.get("v.parentAttribute")); } })Design
<design:component> <design:attribute name="object" /> <design:attribute name="lookupField" /> <design:attribute name="selectedRecordId" /> </design:component>
Child Component
<aura:component access="global" implements="lightning:availableForFlowScreens"> <!-- Determine which actions are available --> <aura:attribute name="canPause" type="Boolean" /> <aura:attribute name="canBack" type="Boolean" /> <aura:attribute name="canNext" type="Boolean" /> <aura:attribute name="canFinish" type="Boolean" /> <aura:attribute name="childAttribute" type="String" /> <aura:handler name="init" value="{!this}" action="{!c.init}" /> <div aura:id="actionButtonBar" class="slds-clearfix slds-p-top_medium"> <!-- If Previous is available, display to the left --> <div class="slds-float_left"> <aura:if isTrue="{!v.canBack}"> <lightning:button aura:id="BACK" label="Previous" variant="neutral" onclick="{!c.onButtonPressed}" /> </aura:if> </div> <div class="slds-float_right"> <!-- If Pause, Next, or Finish are available, display to the right --> <aura:if isTrue="{!v.canPause}"> <lightning:button aura:id="PAUSE" label="Pause" variant="neutral" onclick="{!c.onButtonPressed}" /> </aura:if> <aura:if isTrue="{!v.canNext}"> <lightning:button aura:id="NEXT" label="Next" variant="brand" onclick="{!c.onButtonPressed}" /> </aura:if> <aura:if isTrue="{!v.canFinish}"> <lightning:button aura:id="FINISH" label="Done" variant="brand" onclick="{!c.onButtonPressed}" /> </aura:if> </div> </div> </aura:component>Controller
({ init : function(cmp, event, helper) { // Figure out which buttons to display var availableActions = cmp.get('v.availableActions'); for (var i = 0; i < availableActions.length; i++) { if (availableActions[i] == "PAUSE") { cmp.set("v.canPause", true); } else if (availableActions[i] == "BACK") { cmp.set("v.canBack", true); } else if (availableActions[i] == "NEXT") { cmp.set("v.canNext", true); } else if (availableActions[i] == "FINISH") { cmp.set("v.canFinish", true); } } }, onButtonPressed: function(cmp, event, helper) { var label = cmp.get("v.childAttribute"); var isDefined = !$A.util.isUndefined(cmp.get("v.childAttribute")); console.log(isDefined); console.log(label); if (label) { // Figure out which action was called var actionClicked = event.getSource().getLocalId(); // Fire that action var navigate = cmp.get('v.navigateFlow'); navigate(actionClicked); } else { alert('Last One 10000'); } } })
here is a screenshot showing the two console logs on my Lookupclean after the field is filled
Here is a screenshot showing the two additional console.logs when i press my flowFooter button. the attribute is undefined
Any ideas?