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!!

26 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

  11. very usefull informatation.and iam looking for more posts like this please keep updating us........

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


    Pawn Shop

    Pawn Loans

    Pawn Shops

    Pawn Loan

    Pawn Shop near me

    ReplyDelete
  13. Thank you for your information. It was very easy to understand. You are expressing it in easy way. The images are very helpful. A very useful blog on lightning protection System, I am having this device in my home and also at my office.

    ReplyDelete
  14. This is very useful informative blog.Thanks for shairng information.To get the details about
    Central Government jobs TamilNadu state 2017-18

    ReplyDelete
  15. Nice information thanks for sharing good blogs.More information Visit
    Krishna University Result

    ReplyDelete
  16. Awesome,
    Thank you so much for sharing such an awesome blog...
    iphone training classes in bangalore

    ReplyDelete
  17. This comment has been removed by the author.

    ReplyDelete
  18. Brilliant, One of the best example and code for knowing the user experience and intensive of having the lightning experience or classic view, As I prefer is Classic View because it has the specific importance of having the user experience easy and well understandable As I completed my PMP Certification in Pune I was having the my PC or other resource as a classic View only Thank you so much for the information and your code Well I look forward for more Updates from you

    ReplyDelete
  19. A very helpful blog on surge protection device, I am having this device at my home and also at my office. It is efficiently running since 3 years. No problems as previous was.

    ReplyDelete
  20. Really it was an awesome article...very interesting to read..You have provided an nice article....Thanks for sharing..
    Android Training in Chennai
    Ios Training in Chennai

    ReplyDelete