3

I have a managed app that I spent a few months developing. I tested it in Classic mode. It works great. But then I switched to Lightning mode. Then I try to go to the login page:

/apex/PriLogin

And I get:

Page not found.

Why would this work in Classic mode but not Lightning mode? Some deprecated component? How would I track that down?

This code creates the link:

public static void tellUserToLogin() {

    String message = '<a href="/apex/PrivLogin">You need to login to Priv!</a>';
    ApexPages.Message msgErr = new ApexPages.Message(ApexPages.Severity.ERROR, message);
    ApexPages.addmessage(msgErr);    

}

Which is then shown on the page via:

<apex:pageBlock title="Search PrivCo">
  <apex:pageMessages />
  <apex:pageBlockButtons >

This works fine in Classic Mode.

From Creating Visualforce Pages That Work in Mobile and Desktop:

If the sforce object isn’t available, trying to use it to navigate anywhere results in a JavaScript error, and no navigation. So, instead, the code sets the window’s URL using a Visualforce expression that returns the URL for the account’s detail page. You don’t want to do this in Salesforce1 because the navigation event will be lost by the framework, but it’s required in normal Visualforce.

I don't know the terminology here. What is the sforce object for? I think Salesforce1 is a website that is optimized for cell phones -- I don't need that, so can I ignore that? Is Lightning mode the same as Salesforce1?

  • Comments are not for extended discussion; this conversation has been moved to chat. – Adrian Larson May 1 '17 at 22:10
  • Adrian Larson, this is one of the reasons people complain about StackOverflow communities. The moderation has become more and more heavy-handed. – LRK9 May 1 '17 at 23:36
  • See How do comments work? Comments are temporary "Post-It" notes left on a question or answer. You should not expect them to be around forever: Once a clarification has been made, an edit added to the post to include new information, or the issue in the comment is otherwise resolved, it is subject to deletion. – Adrian Larson May 1 '17 at 23:54
  • Also from that same Meta post: Comments are disposable: unlike posts, there's no revision history, and they can be deleted without warning by their authors, by moderators, and in response to flags. – Adrian Larson May 1 '17 at 23:56
3

I would be happy to be wronged here but to the best of my knowledge, your VF pages will work in lightning as well, it is just that their look n feel would be classic-like. The only problem is the navigation url of yours /apex/PriLogin won't work in lightning the same way as that of the classic.

Workaround

as per the lightning trailhead

This JavaScript fires the Lightning Experience navigateToURL event, and is the equivalent of entering in the classic /apex/PageName URL—you can even see that URL pattern in the code.

javascript:(function(){ 
var pageName = prompt('Visualforce page name:'); 
$A.get("e.force:navigateToURL").setParams(
    {"url": "/apex/" + pageName}).fire();})();

Note The above JS code will not work in Classic, so if you are planning to roll-out your package for both Classic and Lightning then you need set few parameters (i don't know how, as of now) in your app to know whether the user is in Classic or Lex mode.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.