Sep 6, 2016

Lightning experience OR classic view, where am I?

Have you ever faced a problem of identifying in which experience user is opening your page (VFP)? Is it lightning or classic.



Well, here is the solution to it. There are two ways :

1) Via Apex

public boolean isLightningExperience()
{
 if(Apexpages.currentPage().getParameters().get('sfdcIFrameOrigin') != null)
        return true;
 return false;
}

2) Via JS on visualforce page

function isLightningExperience()
{
  if('{!$Currentpage.parameters.sfdcIFrameOrigin}' != '')
  return true;
  return false;
}

You can use two parameters to check this 'sfdcIFrameOrigin' and 'istdp'. Now you can easily identify in which experience the user is via your code and can manipulate the functionality accordingly. 

Happy Coding!!

14 comments:

  1. Nice content. Can we handle the override thing by this ? Suppose we have override the edit button og an object with a vf and i need to show a different lightning component for editing while using lightning experience.

    ReplyDelete
  2. your concept is good, but i have one doubt then how we can write in Soql module can you please explain it.



    Salesforce Training in Chennai

    ReplyDelete
  3. very nice and informative article and useful blog, thank you for sharing with us keep posting
    salesforce training,salesforce online training,online salesforce training

    ReplyDelete
  4. Thanks a lot for offering great informative post. Really liked this awesome post.

    Salesforce Implementation Services

    ReplyDelete
  5. Very informative blog thank you for sharing with us , keep posting learn more about
    salesforce training,salesforce online training

    ReplyDelete
  6. I need a brief explanation coding ,Your simple informative is valuable but not enough for me that i want to know the variations on salesforce classic and lightening experience.



    Salesforce Training in Chennai

    ReplyDelete
  7. This is very informative blog and useful article thank you for sharing with us keep posting more details aboutsalesforce training,salesforce online training

    ReplyDelete
  8. This is very informative blog and nice article , I really like your technique of writing a blog. I book marked it to my bookmark site list and will be checking back in the near future.Salesforce training, salesforce online training

    ReplyDelete


  9. This information is impressive; I am inspired with your post writing style & how continuously you describe this topic.

    Payday loans in Alabama
    Title loans in South Carolina

    ReplyDelete
  10. Thanks for sharing a good information about salesforce . .......This article is very useful to learners. Sales force online training

    ReplyDelete