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
Fred13Fred13 

Navigate back to Original Lightning Component - Not showing New Records

I have a lightning component that calls a second lightning component to clone records.  After I am done on this second component, I want to navigate back to the original and refresh it so it includes the new records.  I am able to return back to the original lightning component but the newly created records are not displaying unless I click refresh on browser.  How can I navigate and refresh?  THis is how I am returning to my original component on save:
 
createClones: function(component, GroupStructures) {
    //Save the expense and update the view
    console.log('### Im in the first function ' );
    this.upsertGS(component, GroupStructures, function(a) {
        //var groupstructures = component.get("v.newGroupStructures");
        GroupStructures.push(a.getReturnValue());
        component.set("v.newGroupStructures", GroupStructures);
    });
  },
    
    upsertGS : function(component, groupstructures, callback) {
        //variable to hold the account id for my naviagation back to original component
        var recordId = component.get("v.existinggroupstructure.Account__c")
        //set urlEvent Variable to navigate back to the original component
        var urlEvent = $A.get("e.force:navigateToURL");
        urlEvent.setParams({
            "url" : "lightning/n/Group_Structures_List?//Aid=" + recordId + "&Tid=123456789"    
        });
		//call apex to save the newly created group structures
  		var action = component.get("c.saveGroupStructure");
        	action.setParams({ 
          	gs: groupstructures
	  });
  if (callback) {
      action.setCallback(this, callback);
  }
        
  $A.enqueueAction(action);
        ///navigate back to groupstructures page
        urlEvent.fire();
},



Thanks!!

Fred
Raj VakatiRaj Vakati
Can you do one think .. You need to call the  init handler on the component when you navigate back tothe component .. 

So you no need to refresh ... 

Can you share the markup ?
Fred13Fred13
Are you asking for the init code for the original component? the one that we are navigating back to?  If so, here is it:
 
doInit : function(component, event, helper) {

     //get the url and split so you get the aid id that is being passed
      	var URLAid = window.location.search.split('//')[1];
     //pull only the actual Account ID
    	 var Aid = URLAid.substring(4,19);
	 //set the Aid attribute on the component so it can be passed to the apex class through the helper
  		 component.set("v.Aid", Aid);
	
        // Retrieve group structure values during component initialization
            helper.loadGroupStructures(component);
        	helper.loadGroupNumbers(component);
        	helper.loadSections(component);
        	helper.loadPackages(component);
        	helper.loadProducts(component);
            helper.updateTotal(component);
		//console.log('### here is the groupStructures recordid var  ' + JSON.stringify(component.get("v.recordId")));	 
       // console.log('### vary' +  JSON.stringify(component.get("v.Aid"),null,4))
       // 
   
    },