I have a lightning component developed to work both in lightning and in community pages(flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes)

To work around LockerService limitations the component performs navigation to a vfpage in order to load a remote js library. Apart from that the vfpage exposes the same lightning component through lightning out option.

In the vfpage I have implemented a few handlers like force:navigateToURL for example to make sure everything continues to work.

              event: "force:navigateToURL",
              handler: function(event) {
                if (window.hasOwnProperty("sforce") && sforce.one) {
                  // VF page in S1 or Lightning Exp
                } else {
                  // VF page in Classic
                  console.log("force:navigateToURL is unimplemented");

So when a link from the lightning component is fired the vfpage is able to handle it. At this point everything works as expected. In my case the navigateToURL is used to jump to another record while reloading the same vfpage and carrying a record id in the query string along with a few other params.

Now, the component works almost the same when dropped in a community site. I say almost because from Lightning I am able to navigate to the vfpage, every feature of the component is working but navigateToURL is not. I debugged the call, I can see that sforce.one.navigateToURL(event.getParam("url")) is actually invoked (event.getParam("url") contains the correct URL, only the path actually, so /apex/pagename?query...) but no navigation is performed and no error is logged in the JavaScript console.

What am I missing?

  • Could it be because of the community URL being different from the SF Org URL? – Dave Humm Sep 6 '17 at 14:41
  • I don't know how that would come into play actually. There's another function I actually use - navigateToSObject - that brings me back to the community lightning record page and that just works. I'm clueless. – shillem Sep 6 '17 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.