4

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

After submitting: enter image description here

After refreshing: enter image description here

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.

  • Do you have two different components for parent and child records? And that you are making edits in child and expect to refresh parent? – Jayant Das Jul 30 '18 at 18:59
  • Have you tried using force:refreshView? It's not the DOM that needs to be updated, it's the underlying data. – sfdcfox Jul 30 '18 at 19:28
  • @JayantDas, No im having only one component, parent info will be rendered using record view form and child records are rendering in the table, when click on save im doing dml and tried to refresh the dom using aura:if. – Yaswanth Tikkisetti Jul 31 '18 at 4:20
  • @sfdcfox, I tried with force:refreshView $A.get('e.force:refreshView').fire(); as well, but it also didn't worked, If we are doing the dom refresh means, respective data also need to refresh right? – Yaswanth Tikkisetti Jul 31 '18 at 4:25
0

did you tried:

<aura:if isTrue="{!v.showViewForm == TRUE}">

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

  • Welcome to SFSE! I'm afraid that this doesn't really provide an answer to the question. This may be more appropriate as a comment. Once you gain enough reputation (50) you'll be able to add comments on other people's questions and answers. Please read How to Answer. As a final note, explicitly checking <boolean variable> == true can be simplified to simply <boolean variable>, which is what OP (Original Poster of the question) currently has. – Derek F Jul 31 '18 at 12:50
  • Thanks Derek! Yeah, I had no other choice - it was more a suggestion then an answer! Thats true, but it would be also false if the attribute is null or undefined - on which I wanted to point out. Greets – Bernhard Miehl Aug 1 '18 at 9:37

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.