12

Is there a way to open VF page in lightning experience using URL link?. I know we can use sforce.one.navigateToURL but in our case it would not work because The URL link is outside the salesforce.

Use case

  • We are sending an vf page link in the email some thing like Click Here <a href="https://na16.visual.force.com/apex/myTask"> Click Here</a>. this is working fine with classic but we are facing the issue if user is in lightning experience.

Issue

  • If user is in lightning experience then this URL link is not working as expected. It's open the VF page but without one.app container.

I have attached the screen short of both classic and lightning experience output.

If user is in classic then URL Link open below screen

enter image description here

If user is in lightning experience then URL Link open below screen

enter image description here

Expected output in lightning experience

enter image description here

Is there any way to get expected output?

  • 6
    In order to resolve this, we have an option.From the email link we redirect the user to a page which checks if the user is lightning enabled or classic, and if the user is lightning enabled, then we append the URL /one/one.app#/alohaRedirect/apex/vfPageName to our URL and use it to redirect to the required page. We just want to know if this is the ideal solution or there is some other option to this. – Sagar Thoriya May 25 '17 at 12:47
  • Could you please let me know how exactly you are doing this check? is it via Javascript or Controller? – Sid Feb 16 '18 at 9:59
5

I would recommend that you add conditional code at the top of your page that determines what environment the User is currently in, then either displays the page using the Lightning experience where it puts the page in a Lightning I-Frame or if the user is in Classic mode, directly displays it without the I-frame. See Sharing Visualforce Pages Between Classic and Lightning Experience which contains the code for how to do this.

  • 1
    Can you guide me how to displays the page using the Lightning experience by using this na16.visual.force.com/apex/myTask kind of URL or is there any way to generate lightning experience URL? for me it's not navigating to lightning UI. – Sagar Thoriya Dec 23 '16 at 4:50
  • How to put the vf page in a Lightning I-Frame ? – Sagar Thoriya Dec 23 '16 at 4:52
  • See the references in the same Module in the section under Exploring the Visualforce App Container. I suggest you go through the entire Module to find the answers to your questions. – crmprogdev Dec 23 '16 at 12:48
  • 1
    @crmprogdev, your link describes conditional behaviour/appearance, based on the current theme. I can't see any mention of adding the Lightning frame. In fact, it says "Lightning Experience is the parent context, and your Visualforce page is the child context. Children need to obey their parents." So I'll be surprised (but happy) if there's a way for users to arrive on the page, the page to detect Lightning Experience is enabled, instantiate the LEX Single Page Application and reparent itself inside of it. Can you elaborate? – frup42 Jan 6 '17 at 10:16
  • @frup42 I can't find the line you quoted on the page I referenced. The parent context is unknown. The JS determines the context from which you can then dynamically use additional JS to initiate the LEX code, the Lightning Frame etc to wrap the VF page inside of. – crmprogdev Jan 6 '17 at 17:53

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.