Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Saturday, July 27, 2019

How to check Forecast is enabled or not for User using SOQL

This simple query checks the forecast is enabled or not user
SELECT Id, ForecastEnabled FROM User where Id = '005B0000005lewT'
Result

Resource
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_user.htm

How to query Salesforce Logged in Users information Using SOQL

This simple SOQL query returns the User Information and logged information in salesforce.
It returns the type of sessions user have a logged-in system.

SOQL Query
Select Id, UsersId, Users.Name, UserType, SourceIp, SessionType, SessionSecurityLevel, ParentId, LoginType, LastModifiedDate, CreatedDate From AuthSession
Result

Resource
AuthSession SOAP API

Thursday, October 25, 2018

Checking UI Theme Detection in Visualforce and Apex

UI Theme Detection can be done in one of two ways:

Accessing global variables:
$User.UITheme – Returns the theme that is supposed to be used.
$User.UIThemeDisplayed – Returns the theme that is actually being used.

Calling Apex utility methods:
UserInfo.UITheme() – Returns the theme that is supposed to be used
UserInfo.UIThemeDisplayed() – Returns the theme that is actually being used

Currently, Salesforce supports below themes
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—Salesforce mobile app theme
Theme4u—Lightning Console theme
PortalDefault—Salesforce Customer Portal theme
Webstore—Salesforce AppExchange theme

UI theme detection using global variables
check below sample code

<apex:page>
    <apex:pageBlock title="My Content" rendered="{!$User.UITheme == 'Theme2'}">
        // this is the old theme...
    </apex:pageBlock>

    <apex:pageBlock title="My Content" rendered="{!$User.UITheme == 'Theme3'}">
       // this is the classic theme ...
    </apex:pageBlock>
</apex:page>

UI theme detection Using Apex Utility Methods
Check below sample code

public with sharing class UIThemeController {
   @AuraEnabled
    public static String getUIThemeDescription() {
        String theme = UserInfo.getUiThemeDisplayed();
        return theme;
    }
}

Use the UI theme detection based on your requirement.
Let us know if you have any queries.
Happy Learning!!!