I have an formula field with HYPERLINK to an VF Page below is the Formula Field code

IF (TEXT(<fld name>) ==  'something', HYPERLINK('/apex/page-name?param1=5&id='+Id, MY BUTTON IMAGE,'_self'), NULL)

The above code generates URL as below (when i see using inspect element)


But on layout when i click on image it redirects to below URL


Can someone explain why is this behaviour.


  • If you're on lightning UI, it would be common as first it would try to open the page in Lightning domain followed by in Classic.
    – Raul
    Commented Apr 19, 2018 at 8:08
  • any solution for this... because if we redirect to a VF page from a Lightning component, it opens up in lightning UI Commented Apr 19, 2018 at 11:25
  • What's the problem with that?
    – Raul
    Commented Apr 19, 2018 at 12:06
  • problem is only with url within formula, it doesn't work as redirect work within lightning component Commented Apr 19, 2018 at 12:58

1 Answer 1


Lightning and classic url is different. to resolve this condition on redirected page you can use this script as a reference.

"script" if(typeof sforce !== 'undefined' && sforce !== null && '{!$User.UIThemeDisplayed}' === 'Theme4d'){ sforce.one.navigateToURL('{!'/one/one.app#/ }'); } else { window.top.location = '{!'/}'; } "/script"

Hope this helps !!

  • how this would work in formula field ?? Commented Apr 19, 2018 at 11:22
  • formula field you are using to redirecting to vf page is fine. you can write that script to redirect to lightning mode instead of classic one. i don't think you can achieve this by formula. Commented Apr 19, 2018 at 11:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .