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
Tim Miller 26Tim Miller 26 

Redirecting from a lightning app back to a tab default view for a Lead or contact

I have a lightning app that when the cancel button is pressed, I try to redirect to a tab default view for the Lead object or Contact object it opens up a lightning page inside a lightning page.
Screenshot of double Screens in Lightning 
Here is my code for the cancel button event:

cancelEvent : function(component, event, helper) {
     var address = 'https://rv--timdev.lightning.force.com/one/one.app#/sObject/Lead/list?filterName=Recent';
      window.location.href = address; 
}

I have tired using force:navigateToURL and force:navigateToObject and never can get those to work. here is my example:
cancelEvent : function(component, event, helper) {
     var address = 'https://rv--dev.lightning.force.com/one/one.app#/sObject/Lead/list?filterName=Recent';
     var urlEvent = $A.get("e.force:navigateToURL");
     urlEvent.setParams({
          "url": address
     });
     urlEvent.fire();
}
  1. why do I get the lightning window in the lightning window?  is it due to lightnings iframe?
  2. why doesn't the navigateToURL work?


 
Yachana YachanaYachana Yachana
Yes, the reason is iframe here thats why navigateToURL  is also not working. Try this code by replacing  window.location.href = address; 
           if((typeof sforce != 'undefined') && sforce && (!!sforce.one))
          sforce.one.navigateToSObject(account.Id);
          else
              window.location = "/"+account.Id;

If this resolves your issue please mark as best answer.