Tag Archives: SFDC

Hide Header and Sidebar in Salesforce

Sometimes we need to hide header and sidebar of a Visualforce page or Standard layout. So here are some ways to hide header and sidebar for Salesforce Visualforce page and Standard layout.

Generally in Visualforce Page we use sidebar="false" to hide sidebar. To hide header and chat widget we use header="false" and showChat="false" respectively.

  • Hide Header and Sidebar from Visualforce Page with specifying header="false" and sidebar="false".
<apex:page showHeader="false" sidebar="false">
</apex:page>
  • Hide Header and Sidebar from Visualforce Page or Standard Layout by adding isdtp parameter in the URL. The main purpose of isdtp can be used to hide Salesforce header and sidebar on Standard Pages.
    • vw – The Visualforce page will be rendered without header and sidebar, supports aloha theme, allows chatter.
    • lt – leaves off SF formatting, page header, sidebar, tabs and section header.
    • nv – The page will be rendered without the tabs and sidebar, and will accommodate all the buttons in a list view.
    • mn – Retains Old Salesforce Styling, hides page header(tabs) and sidebar.
PageReference pgref = new PageReference('/apex/pagename?recordId&isdtp=vw);
https://ap1.salesforce.com/001?fcf=00B90000008Ajal?isdtp=vw
  • Hide Sidebar from Standard layout.
    Go to – Setup || Customize || User Interface – checked the check box “Enable Collapsible Section”. After that you can show or hide sidebar in Standard layout.

Get Salesforce Base URL in Visualforce Page

Apex Class:

public class SampleBaseURL{

    public List<Account> accList {get;set;}
    
    public SampleBaseURL(){
        accList = [SELECT Id, Name FROM Account LIMIT 100];
    }
}

Visualforce Page:

<apex:page controller="SampleBaseURL" sidebar="false">
    <apex:repeat value="{!accList}" var="a">
        <a href="{!$Site.BaseUrl}/{!a.Id}" target="_blank">{!a.Name}</a>
    </apex:repeat>
</apex:page>

Output:

Enable Organization Admins to Login as Any User

Go to Administer | Security Controls | Login Access Policies | Select Administrators Can Log in as Any User

With this feature enabled, System Administrators can log in as any user in their organization without asking internal end-users to grant login access.

Note: This feature is available in Enterprise, Performance, Unlimited and Developer Editions. If this feature is not found in your Org, contact Salesforce.com support to enable.

How to create a report that shows user license?

To display Salesforce as a User License type on report, Below is the workaround:

  • Create a Custom Formula Text field under the User object:
    1. Go to Setup | Customize | Users | Fields
    2. Click on New and select “Formula” field type and then “Text”
    3. Use “Profile.UserLicense.Name” in the formula editor
    4. Click on Save
  • Create a New Administrative User report:
    1. Go to the Report tab
    2. Click on New report
    3. Under the Administrative reports | Select Users
    4. Add the New Custom Formula field in the report
    5. Run the Report and Save

SOQL Query To Get Users with Salesforce User License

Get all Users with User License:

List<User> userList = [Select Id, Name, Profile.UserLicense.Name From User];

Get Users with specific User License:

List<User> userList = [Select Id, Name, Profile.UserLicense.Name From User WHERE Profile.UserLicense.Name = 'Salesforce'];