Skip to main content
added 147 characters in body
Source Link
 public static string isLightningExperience()
 {
        boolean isLightningExperience = false;
        string id = UserInfo.getUserId();
        for (User u: [SELECT Id, UserPreferencesLightningExperiencePreferred FROM User WHERE Id =: id LIMIT 1])
        {
            isLightningExperience = u.UserPreferencesLightningExperiencePreferred;
        }
        return string.valueOf(isLightningExperience);
 }

this function return true ,the value of the field UserPreferencesLightningExperiencePreferred in the object user change when the user interface switch. if UserPreferencesLightningExperiencePreferred is ture => Lightning Desktop and return false, if false => Classic Desktop

 public static string isLightningExperience()
 {
        boolean isLightningExperience = false;
        string id = UserInfo.getUserId();
        for (User u: [SELECT Id, UserPreferencesLightningExperiencePreferred FROM User WHERE Id =: id LIMIT 1])
        {
            isLightningExperience = u.UserPreferencesLightningExperiencePreferred;
        }
        return string.valueOf(isLightningExperience);
 }

this function return true , if is Lightning Desktop and return false if Classic Desktop

 public static string isLightningExperience()
 {
        boolean isLightningExperience = false;
        string id = UserInfo.getUserId();
        for (User u: [SELECT Id, UserPreferencesLightningExperiencePreferred FROM User WHERE Id =: id LIMIT 1])
        {
            isLightningExperience = u.UserPreferencesLightningExperiencePreferred;
        }
        return string.valueOf(isLightningExperience);
 }

the value of the field UserPreferencesLightningExperiencePreferred in the object user change when the user interface switch. if UserPreferencesLightningExperiencePreferred is ture => Lightning Desktop , if false => Classic Desktop

added 91 characters in body
Source Link
 public static string isLightningExperience()
 {
        boolean isLightningExperience = false;
        string id = UserInfo.getUserId();
        for (User u: [SELECT Id, UserPreferencesLightningExperiencePreferred FROM User WHERE Id =: id LIMIT 1])
        {
            isLightningExperience = u.UserPreferencesLightningExperiencePreferred;
        }
        return string.valueOf(isLightningExperience);
 }

this function return true , if is Lightning Desktop and return false if Classic Desktop

 public static string isLightningExperience()
 {
        boolean isLightningExperience = false;
        string id = UserInfo.getUserId();
        for (User u: [SELECT Id, UserPreferencesLightningExperiencePreferred FROM User WHERE Id =: id LIMIT 1])
        {
            isLightningExperience = u.UserPreferencesLightningExperiencePreferred;
        }
        return string.valueOf(isLightningExperience);
 }
 public static string isLightningExperience()
 {
        boolean isLightningExperience = false;
        string id = UserInfo.getUserId();
        for (User u: [SELECT Id, UserPreferencesLightningExperiencePreferred FROM User WHERE Id =: id LIMIT 1])
        {
            isLightningExperience = u.UserPreferencesLightningExperiencePreferred;
        }
        return string.valueOf(isLightningExperience);
 }

this function return true , if is Lightning Desktop and return false if Classic Desktop

Put code in code block
Source Link
Reshma
  • 4.1k
  • 7
  • 29
  • 43

public static string isLightningExperience() { boolean isLightningExperience = false; string id = UserInfo.getUserId(); for (User u: [SELECT Id, UserPreferencesLightningExperiencePreferred FROM User WHERE Id =: id LIMIT 1]) { isLightningExperience = u.UserPreferencesLightningExperiencePreferred; } return string.valueOf(isLightningExperience); }

 public static string isLightningExperience()
 {
        boolean isLightningExperience = false;
        string id = UserInfo.getUserId();
        for (User u: [SELECT Id, UserPreferencesLightningExperiencePreferred FROM User WHERE Id =: id LIMIT 1])
        {
            isLightningExperience = u.UserPreferencesLightningExperiencePreferred;
        }
        return string.valueOf(isLightningExperience);
 }

public static string isLightningExperience() { boolean isLightningExperience = false; string id = UserInfo.getUserId(); for (User u: [SELECT Id, UserPreferencesLightningExperiencePreferred FROM User WHERE Id =: id LIMIT 1]) { isLightningExperience = u.UserPreferencesLightningExperiencePreferred; } return string.valueOf(isLightningExperience); }

 public static string isLightningExperience()
 {
        boolean isLightningExperience = false;
        string id = UserInfo.getUserId();
        for (User u: [SELECT Id, UserPreferencesLightningExperiencePreferred FROM User WHERE Id =: id LIMIT 1])
        {
            isLightningExperience = u.UserPreferencesLightningExperiencePreferred;
        }
        return string.valueOf(isLightningExperience);
 }
Source Link
Loading