I'm having TestObject as parent object and New Custom Object having M-D relationship to it. TestObject having Min and Max Rollup summary fields which will rollup number field in child object.
I was rendering parent information using lightning:recordViewForm with certain fields, if we perform any dml in child need to refresh the parent record information.
Here's my Markup code:
<aura:if isTrue="{!v.showViewForm}">
<lightning:recordViewForm recordId="a0G2800000KJxZp" objectApiName="TestObject__c">
<lightning:layout class=" slds-wrap custom-layout">
<lightning:layoutItem size="4" padding="around-small">
<lightning:outputField fieldName="Name" class="output-element"/>
</lightning:layoutItem>
<lightning:layoutItem size="4" padding="around-small">
<lightning:outputField fieldName="Max__c" class="output-element"/>
</lightning:layoutItem>
<lightning:layoutItem size="4" padding="around-small">
<lightning:outputField fieldName="Min__c" class="output-element"/>
</lightning:layoutItem>
</lightning:layout>
</lightning:recordViewForm>
</aura:if>
Whenever i was updating child records, i just need to refresh the parent details.
I tried with setting boolean variable false before making dml, after success callback making the boolean as true, but it didn't reflected.
Here's controller code:
update : function(component, event, helper) {
component.set("v.showViewForm", false);
var action = component.get("c.updateParentValues");
action.setParams({
'updateList': component.get("v.records")
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
component.set("v.showViewForm", true);
component.set("v.records", response.getReturnValue());
}
});
$A.enqueueAction(action);
}
Here's my screen shots
Upto my knowledge when we are rebuilding the dom using aura:if it should refresh.
Did i missed anything here (or) Is there any other alternative approaches to refresh the record view form.
I tried with lightning:recordForm as well.
Best Answer
did you tried:
I guess, the condition is also true, if you have defined some default value for v.showViewForm, because it checks if the attribute is set.
Let me know, if this helps
Greets, Bernhard