• Serhiy Fyrin
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Greetings!

sforce.one.navigateToURL() fails to navigate from Visualforce page tab to Lightning component tab. The issue started happening under Lightning experience since Winter 17 upgrade. It looks like something that should be fixed by Salesforce development on Salesforce side. Steps to reproduce are provided bellow.

Repro
~~~~~

1. Create a simple Lightning component with name "NavigateToURLTest" and the following code:
 
<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable"
access="global"
>
<div style="text-align: center; font-size: 30px; padding-top: 100px;">
NavigateToURLTest Lightning Component
</div>
</aura:component>

2. Create a Lightning component tab with the same name "NavigateToURLTest" and add
it to Lightning navigation menu. 

3. Reload the app in a browser and click on the newly added "NavigateToURLTest" menu
item. After the component shows up copy a local part of a URL from browser address bar. This local URL will be used to navigate from Visualforce page. It should look like this:

/one/one.app#eyJjb21wb25lbnREZWYiOiJvbmU6YXVyYUNvbnRhaW5lciIsImF0dHJpYnV0ZXMiOnsidmFsdWVzIjp7InRhZyI6ImM6TmF2aWdhdGVUb1VSTFRlc3QifX0sInQiOjE0NzcxNzI5MTc1NjV9

4. Create a Visualforce page with the same name "NavigateToURLTest" and the following code:
<apex:page >
<div style="text-align: center; font-size: 30px; padding-top: 100px;">
NavigateToURLTest Visualforce page
</div>
<div style="text-align: center; padding-top: 30px;">
<button style="font-size: 20px; padding: 15px;" onclick="ntut_Navigate();">Click to Navigate</button>
</div>
<script type="text/javascript">
function ntut_Navigate() {
// NOTE: paste here local URL from step 3
var url = '/one/one.app#eyJjb21wb25lbnREZWYiOiJvbmU6YXVyYUNvbnRhaW5lciIsImF0dHJpYnV0ZXMiOnsidmFsdWVzIjp7InRhZyI6ImM6TmF2aWdhdGVUb1VSTFRlc3QifX0sInQiOjE0NzcxNzI5MTc1NjV9';
sforce.one.navigateToURL(url, true);
};
</script>
</apex:page>

5. Mark the Visualforce page as "Available for Salesforce mobile apps and Lightning Pages".

6. Create a VIsualforce page tab with name "NavigateToURLVisualforce" and add it to Lightning navigation menu.

7. Reload the app in a browser and click on the newly added "NavigateToURLTest" menu item. Then click on "Click to Navigate" button.

8. Actual result: an error "Something has gone wrong. $A.getDefinition. Please try again." is displayed and navigation does not happen.

9. Expected result: application navigates to "NavigateToURLTest" tab. This was working fine until Winter 17 upgrade.

10. Additional information: a result URL that the app navigates to has the following structure (after base64-url decoding):
 
{"componentDef":"eyJjb21wb25lbnREZWYiOiJvbmU6YXVyYUNvbnRhaW5lciIsImF0dHJpYnV0ZXMiOnsidmFsdWVzIjp7InRhZyI6ImM6TmF2aWdhdGVUb1VSTFRlc3QifX0sInQiOjE0NzcxNzI5MTc1NjV9","attributes":{"values":{"tag":"c:NavigateToURLTest"}},"t":1477172917565}

instead of correct initial value:
 
{"componentDef":"one:auraContainer","attributes":{"values":{"tag":"c:NavigateToURLTest"}},"t":1477172917565}

Workaround
``````````
There is no workaround.

Hi,

 

I have a visualforce page that may need to run in an iFrame.  When a user hits a commandbutton, I need it to call an Apex method (to update some records) but then I'd like to be able to have the entire window (not just the iFrame) load the return URL.  Is this possible?

 

It doesn't look like there's any way to set a target on a pagereference, but what I want to do is something like:

 

 

public PageReference submitConfirmation() {

     PageReference pr = new PageReference('urlgoeshere.com');

     pr.setTarget('_top'); // this line is NOT real code - there is no such PageReference method

     return pr;

}

 

 

Any advice?

 

Thanks,

 Drew