Thursday, September 28, 2017

What makes Visualforce In Salesforce Classic & Lightning Experience different?


1) Development Mode for Visualforce is only available in Salesforce Classic and not in Lightning.

2) Pages you view using direct URL access always display in Salesforce Classic and not in Lightning. The reason is in order to view your page in Lightning Experience, you need to access the Lightning Experience container app. This means accessing /one/one.app. If you’re accessing that, you can’t access /apex/PageName. They’re just two different URLs that don’t overlap.

To test your page in Lightning Experience, add the following bookmarklet to your browser’s menu or toolbar -

javascript:(function(){ 

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

3) Use the $User.UITheme and $User.UIThemeDisplayed global variables to determine the current user experience context in Visualforce context. These global variables return a string that uniquely identifies the current user interface context. The difference between the two variables is that $User.UITheme returns the look and feel the user is supposed to see, while $User.UIThemeDisplayed returns the look and feel the user actually sees. 

The possible values for $User.UITheme and $User.UIThemeDisplayed are the same:

  • Theme1—Obsolete Salesforce theme
  • Theme2—Salesforce Classic 2005 user interface theme
  • Theme3—Salesforce Classic 2010 user interface theme
  • Theme4d—Modern “Lightning Experience” Salesforce theme
  • Theme4t—Salesforce1 mobile Salesforce theme
  • PortalDefault—Salesforce Customer Portal theme
  • Webstore—Salesforce AppExchange theme

4) Use the UserInfo.getUiTheme() and UserInfo.getUiThemeDisplayed() system methods to determine the current user experience context in Apex code. The possible values returned by these methods are the same as those returned by the $User.UITheme and $User.UIThemeDisplayed global variables.

5) Lightning Experience manages navigation using "Events" (use 'sforce.one' object) while in Salesforce Classic we have "PageReference" for performing navigation actions.

6) Use <apex:slds> component to reference Lightning Design System stylesheets without uploading them as a static resource, simplifying the syntax of your page and preventing you from hitting the 250-mb static resource limit.

7) Some more differences that we can make in between Visualforce page running in Salesforce Classic compared to Lightning Experience are -

a) In Salesforce Classic, Visualforce “owns” the page. But in Lightning Experience, Visualforce runs inside an iframe that’s wrapped inside the larger Lightning Experience container.
b) Lightning Experience and Visualforce pages are not only held in different browser contexts, they’re also served from different domains. So, even though it’s all showing in one browser window, the session ID inside the Visualforce iframe will be different than the session ID outside the iframe, in another part of Lightning Experience.
c) <apex:page> showHeader and sidebar attributes are always false.




Happy Weekend Friends!!!! 😊

Thursday, September 14, 2017

Handling TimeZone Conversion in Apex

Before the week ends, here's my next post on handling TimeZone conversion in Apex -

a) Developers might have datetime issue reported before in existing application. This is a good reference for timezone conversion in apex.

http://www.force2b.net/index.php/2010/08/date-time-and-timezone-handling-in-apex/
-------------------------------------------------------------------------------------------------------------------

b) Another way to retrieve SFDC default timezone  from User object :

Schema.DescribeFieldResult fieldResult = User.TimeZoneSidKey.getdescribe();

List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

for(Schema.PicklistEntry p : ple){
system.debug('###'+p.getlabel()+'****'+p.getValue()+'\n');
}

Please leave your comment if you agree or have any better approach of handling TimeZone conversion in Apex.

Monday, September 11, 2017

New Start on Salesforce Blogging!

Hi Friends,

This is my first blog that I am starting today with. Introducing myself first. I am Ajit Kumar Surana working as Senior Salesforce Developer in HTC Global Services, Malaysia. I have been working on Salesforce since 2013. And by far, I am really enjoying my professional career being as Salesforce developer.

This blog is to help my friends who are working on Salesforce and stuck with common issues which we face while we do development and also to share coming new features on Salesforce platform. I will try to keep the content relevant and updated. Please don't forget to leave your comment if you have any questions related to my blog.

Last but not the least, I would like to use this place to thank all my previous organisations, mentors and  ex-colleagues who gave me a chance to start my career on Salesforce and helping me out during my development career.

Thanks to all who visited my blog page and read this blog completely! 😏

Cheers!!!!

Will post my second blog soon.....!!!