function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NeedHelp55NeedHelp55 

Updated value is not showing after redirection in Lightning component.

I am using one lightning component with one lightning out and app referred in a visualforce component.

My goal is to update a record on a button click and if the operation is successfull then it will take the user to detail page of updated record[  with updated values].

Below are the componets. Redirection is working fine but the updated value are not reflecting on detail page after redirected from button click.
I am getting updated values after i am doing page refresh by myself.

Please help. I am stuck on this point from a long time.
Lightning Component
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" controller="RFID_varianceReportController">
    <ltng:require styles="/resource/LightningCSS/assets/styles/salesforce-lightning-design-system.css" />
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="cycleLineItemSize" type="Integer" />
    <aura:attribute name="cycleCountLineItem" type="RFID_Cycle_Count_Variance_Reports__c[]" default="{ 'sobjectType' : 'RFID_Cycle_Count_Variance_Reports__c','Reconcilation_Action__c' : 'Bill Customer','Comments__c' : 'Comments'}"/>
    <aura:attribute name="errorMsgSave" type="string"/>
    <aura:attribute name="modalActive" type="Boolean" default="false"/>
    <aura:dependency resource="markup://force:*" type="EVENT"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    <aura:if isTrue="{!v.modalActive == true}">    
        <c:ConfirmSubmission/>
    </aura:if>    
    <!--Use a data table from the Lightning Design System:https://www.lightningdesignsystem.com/components/data-tables/-->
    <div class="slds-theme_shade" aura:id="tableContainer">
    <section class="slds-card__body"> 
    
    <div class="slds-p-vertical--medium" align="center" id="errormessageSubmitSave"> 
        <ui:outputText value="{!v.errorMsgSave}" class="errormsg" aura:id="errormsgBlock"/> 
    </div>

    <aura:if isTrue="{!equals(v.cycleLineItemSize,0)}">
        <div>No Records available to display.</div>
    </aura:if>
        
    <ui:scrollerWrapper class="sWrapTest">    
    <aura:if isTrue="{!greaterthan(v.cycleLineItemSize,0)}">
    <table class="slds-table slds-table_bordered slds-table--cell-buffer slds-max-medium-table--stacked">
    <thead>
        <tr class="slds-text-title--caps">
            <th scope="col" class="slds-cell-wrap">
                <div class="slds-grid slds-wrap">
                    <div title="UPN" class="slds-col slds-size_1-of-8"><ui:outputText value="UPN"/></div>
                </div>
            </th>
            <th scope="col" class="slds-cell-wrap">
                <div class="slds-grid slds-wrap">
                    <div title="Batch" class="slds-col slds-size_1-of-8">Batch</div>
                </div>
            </th>
            <th scope="col" class="slds-cell-wrap">
                <div class="slds-grid slds-wrap">
                    <div title="Serial" class="slds-col slds-size_1-of-8">Serial</div>
                </div>
            </th>
            <th scope="col">
                <div class="slds-grid slds-wrap">
                    <div title="Var" class="slds-col slds-size_1-of-12 slds-cell-shrink">Var</div>
                </div>
            </th>
            <th scope="col">
                <div class="slds-grid slds-wrap">
                    <div title="UOM" class="slds-col slds-size_1-of-12 slds-cell-shrink">UOM</div>
                </div>
            </th>
            <th scope="col" class="slds-cell-wrap">
                <div class="slds-grid slds-wrap">
                    <div title="Reconcile Action" class="slds-col slds-size_2-of-8">Reconcile Action</div>
                </div>
            </th>
            <th scope="col">
                <div class="slds-grid slds-wrap">
                    <div title="Comments" class="slds-col slds-size_2-of-8">Comments</div>
                </div>
            </th>
      </tr> 
    </thead>
        <tbody>
        <aura:iteration items="{!v.cycleCountLineItem}" var="obj" indexVar="i" aura:id="inputCmp">
            <tr>
                <td data-label="UPN" class="slds-cell-wrap">
                    <div title="{!obj.UPN__c}" class="slds-grid slds-wrap">
                        <div class="slds-col slds-size_1-of-8"><ui:outputText value="{!obj.UPN__c}"/></div>
                    </div>
                </td>
                <td data-label="Batch" class="slds-cell-wrap">
                    <div title="{!obj.Batch_Number__c}" class="slds-grid slds-wrap">
                        <div class="slds-col slds-size_1-of-8"><ui:outputText value="{!obj.Batch_Number__c}"/></div>
                    </div>
                </td>
                <td data-label="Serial" class="slds-cell-wrap">
                    <div title="{!obj.Serial_Number__c}" class="slds-grid slds-wrap">
                        <div class="slds-col slds-size_1-of-8"><ui:outputText value="{!obj.Serial_Number__c}"/></div>
                    </div>
                </td>
                <td data-label="Var">
                    <div title="{!obj.Variance_quantity__c}" class="slds-grid slds-wrap">
                        <div class="slds-col slds-size_1-of-12 slds-cell-shrink"><ui:outputText value="{!obj.Variance_quantity__c}"/></div>
                    </div>    
                </td>
                <td data-label="UOM">
                    <div title="{!obj.No_of_sheets__c}" class="slds-grid slds-wrap">
                        <div class="slds-col slds-size_1-of-12 slds-cell-shrink"><ui:outputText value="{!obj.No_of_sheets__c}"/></div>
                    </div>
                </td>
                <td data-label="Reconcile Action">
                    <div title="{!obj.Reconcilation_Action__c}" class="slds-grid slds-wrap">
                        <div class="slds-col slds-size_2-of-8">
                        <ui:inputSelect value="{!obj.Reconcilation_Action__c}" required="true" aura:id="selAura" class="slds-select slds-lookup__search-input slds-input">
                            <ui:inputSelectOption text="" label=""/>
                            <ui:inputSelectOption text="Bill Customer" label="Bill Customer" value="true"/>
                            <ui:inputSelectOption text="In Transit" label="In Transit"/>    
                            <ui:inputSelectOption text="Loaned out (to be returned)" label="Loaned out (to be returned)"/>   
                            <ui:inputSelectOption text="Pending Bill" label="Pending Bill" value="true"/>
                            <ui:inputSelectOption text="Pending Transfer" label="Pending Transfer"/>
                            <ui:inputSelectOption text="Pending Return" label="Pending Return"/>
                            <ui:inputSelectOption text="Product Found (previously missing)" label="Product Found (previously missing)"/>                 
                            <ui:inputSelectOption text="Pending Bonus" label="Pending Bonus"/>                 
                            <ui:inputSelectOption text="Pending Performance" label="Pending Performance"/>                 
                            <ui:inputSelectOption text="Pending PO#" label="Pending PO#"/>                 
                            <ui:inputSelectOption text="Requires Investigation" label="Requires Investigation"/>
                            <ui:inputSelectOption text="Other" label="Other"/>                 
                        </ui:inputSelect>
                    </div>
                    </div>    
                </td>
                <td data-label="Comment">
                    <div class="slds-grid slds-wrap">
                        <div class="slds-col slds-size_2-of-8"><ui:inputTextarea aura:id="commentBox" value="{!obj.Comments__c}" class="slds-textarea"/></div>
                    </div>    
                </td>
            </tr>
        </aura:iteration>
        </tbody>
    
    </table>
        <div class="slds-align_absolute-center">
            <lightning:button label="Submit" class="slds-button_brand" onclick="{!c.updateHeader}"/>
            <lightning:button label="Save" class="slds-button_brand" onclick="{!c.save}"/>
            <lightning:button label="Cancel" class="slds-button_brand" onclick="{!c.cancel}"/>
        </div>
    </aura:if>    
    </ui:scrollerWrapper>   
    </section>    
    </div>
</aura:component>

Javascript Method : 
updateHeader : function(component, event, helper) {
        var confirmmsg = confirm("Are you sure you want to save?");
        var currecId = component.get("v.recordId");
        
        if(confirmmsg == true) {
        var action = component.get("c.submitVariance");
        //component.set('v.modalActive', true);
        
            
        action.setParams({
            "headerId": component.get("v.recordId")
        });
        action.setCallback(this, function(actionResult) {
            var a = actionResult.getState();
            var currecId = component.get("v.recordId");
            console.log(a); 
            if(a == 'SUCCESS') {
                component.set("v.errorMsgSave","Record successfully submitted");
                var event = $A.get("e.force:navigateToSObject");
        //var event = $A.get('e.force:navigateToObjectHome');

        event.setParams({
            "recordId": currecId,
            "slideDevName" : "detail",
            "isredirect" : true
        });   
        event.fire();
                //sforce.one.navigateToSObject(currecId,"detail");
            }
            else if(a == 'ERROR')
                component.set("v.errorMsgSave",a.getError()[0].message);
            else if(a == 'INCOMPLETE')
                component.set("v.errorMsgSave","User or Server is offline");
            
            //alert('Hi');
            //window.location.href = 'javascript:sforce.one.navigateToURL(\'' + '/'+currecId + '\')';
            
            //sforce.one.navigateToSObject(currecId,"detail");
        });
        $A.enqueueAction(action);
        }
    },

Associated Visualforce Page : 
<apex:page standardController="RFID_Cycle_Count__c" extensions="RFID_varianceReportController" standardStylesheets="false">
<apex:includeScript value="/canvas/sdk/js/publisher.js" />
<apex:includeLightning />
  <script>
      var headerId = '{!recordId}';
      $Lightning.use("c:VarianceReport", function() {
                      $Lightning.createComponent("c:Reconcile",
                      {recordId:headerId},
                      "LtngOutBsicInfo",
                      function(cmp) {
                         $A.eventService.addHandler({
                         event: 'force:navigateToSObject',
                         handler: function(event) {
                             if (sforce && sforce.one) {
                                 Sfdc.canvas.publisher.publish({ name : "publisher.close", payload : { refresh:"true" }});
sforce.one.navigateToSObject(event.getParams().recordId); 
                                 
                             }
                         }
                         }); 
                         console.log('component created');
                      });
                  });
    
  </script>
  <body>
  <div Id="LtngOutBsicInfo"></div>
  </body>
</apex:page>