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
Charlotte GibsonCharlotte Gibson 

SF1: navigateToComponent from Visualforce

I'm trying to get a link on a VF page in SF1 to navigate to a Lightning component. I can do Lightning-component-to-Lightning-component navigation, and Lightning-component-to-VF page navigation, but I'm struggling with the JavaScript syntax for VF-to-Lightning-component navigation.

Here's my code snippet - the JS is basically taken from the component-to-component nav snippet (which works a treat when launced via a ui:button press attribute in a Lightning component):
<apex:page showHeader="true" sidebar="true">

<script>
    function navToPlotList(devId, devName){
      console.log('dev id: ' + devId);
      console.log('dev name: ' + devName);

          var button = $A.get("e.force:navigateToComponent");
          button.setParams({
            componentDef:"c:pb_plotList",
            componentAttributes: {
              devId: component.get("devId"),
              devName: component.get("devName")
            }

          });
          button.fire(); 
    }

</script>

<a href="#" onClick="navToPlotList('a06L000000GdS7X', 'TEST NAME')">Go to plot list</a>

I know that the issue right now is with the $A on line 8, but I'm not sure what to replace this with in order to get this working. Also I'm not sure whether the button.fire(); will even work from JS in a VF page. Any thoughts? Thanks in advance! :)
Faisal BahadurFaisal Bahadur

Hi,

$A refers Aura Instance and its not avalible in visualforce.

Charlotte GibsonCharlotte Gibson
Hi Faisal,

Thanks for coming back to me. I know that $A refers to Aura, and is not available in Visualforce - I mostly left it in there so I could demonstrate the Lightning functionality that I need to replicate within Visualforce. I'm hoping that someone will know of an alternative way of navigating to a Lightning component from a Visualforce page which is currently sitting in a lightning component and viewable from the one/one.app.

I have a case open with SF Support just now to see if they can confirm whether it's even possible - I'll report back once I've heard back from them. :)
Charlotte GibsonCharlotte Gibson
Here's the reply from Doug Chasman via my case with Salesforce, specifically in relation to navigating from a SF1 enabled VF page, to a custom Lightning component:

"There is no supported way to do this yet - I have been making a fair amount of noise about this feature request with the folks that own S1/SFX and will let you know when I hear of any developments."

Also, Doug confirmed what others have been reporting over on StackExchange - the navigateToComponent was never officially supported and has now been disallowed with Summer 15:

"The loophole client side that "leaked" this access="private" event has been closed. In addition because this was never a supported API the event's structure an and will change or be completely removed. In fact the event has been reworked in Winter '16 in incompatible ways already."
 
Faisal BahadurFaisal Bahadur

Hi Charlotte Gibson,

Thanks for sharing feedback.