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
Serhiy FyrinSerhiy Fyrin 

sforce.one.navigateToURL() fails to navigate from Visualforce page tab to Lightning component tab

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.
Sergio López CalvoSergio López Calvo
Hi, 

I´m affected by this problem,  "Something has gone wrong. $A.getDefinition. Please try again." , no body knows about, I need help¡¡

Please, if anybody knows something about, response me.

Thanks...