0

So I have a very simple component that has force:recordData. Since it is not a synchronous operation, initially simpleRecord attribute shows null in init handler.

In updateRec method, I can see the field values present in simpleRecord.

However In<aura:if> block never gets re-evaluated (i.e. simpleRecord is always null) and i cannot see the button?

 <force:recordData aura:id="recordLoader"
                          recordId="{!v.recordId}"
                          fields="Id, Name"
                          mode="VIEW"

                          targetRecord="{!v.record}"
                          targetFields="{!v.simpleRecord}"
                          targetError="{!v.recordError}"
                          recordUpdated = "{!v.updateRec}"
                          />

<aura:if isTrue="{!not(empty(v.simpleRecord))}">
    <lightning:button label="Simple Buttn" />
</aura:if>

Plz help me in solving this problem.

1

This is one of the inherent problems with the two-way data binding bugs in Aura. To fix this, you simply need to reset the value to fire an aura:valueChange event.

recordUpdated = "{!v.updateRec}"

...

updateRec: function(component, event, helper) {
  component.set("v.simpleRecord", component.get("v.simpleRecord"));
}
| improve this answer | |
  • Even inside updateRec method, component.get("v.simpleRecord") returns null sometime. It does not return null all the time but only sometime (inside updateRec method). Could this be an issue or is there any other solution? If i refresh the page like 10 times then at least one time I am seeing null value @sfdcfox – lambad Apr 12 at 9:47
  • @lambad You'd have to check the error message when that happens. It should not ordinarily be null. – sfdcfox Apr 12 at 15:04

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.