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 Answer 1

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"));
}
2
  • 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
    Commented Apr 12, 2020 at 9:47
  • @lambad You'd have to check the error message when that happens. It should not ordinarily be null.
    – sfdcfox
    Commented Apr 12, 2020 at 15:04

You must log in to answer this question.

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