What is granular locking in Salesforce?

By default, the Force.com platform locks the entire group membership table to protect data integrity when Salesforce makes changes to roles and groups. This locking makes it impossible to process group changes in multiple threads to increase throughput on updates. When the granular locking feature is enabled, the system employs additional logic to allow multiple updates to proceed simultaneously if there is no hierarchical or other relationship between the roles or groups involved in the updates.

Check the below link for more information



In what ways that SOQL differs from SQL

Here are some ways that SOQL differs from SQL.

No INSERT, UPDATE or DELETE statements, only SELECT
No command execution
No wild cards for fields; all fields must be explicitly typed
No JOIN statement; however, you can include information from parent objects like Select name, phone, account.name from contact
No UNION operator
Queries cannot be chained together


Platform Encoding in Visualforce

In Visualforce, the platform has three main encoding functions that developers can use to neutralize potential XSS threats: HTMLENCODE, JSENCODE, and JSINHTMLENCODE. To choose which encoding to use, consider how your browser is parsing the output.

* If the value is going to be parsed by the JavaScript parser, use JSENCODE().
* If the value is going to be parsed by the HTML parser, use HTMLENCODE().
* If it’s a combination of both …


What is the Apex Crypto Class?

As per the Crypto Class documentation in the Apex Developer's Guide, the Apex Crypto class provides a number of cryptographic functions for creating digests, message authentication codes, and signatures, as well as functions for encrypting and decrypting information. These functions allow you to protect the confidentiality of data as well as allow external systems to verify the integrity of messages and authenticity of the sender.

Check the below link for more information



Formula field to find Time Zone from State field in Salesforce

Formula field to find Time Zone from State field in Salesforce

IF(CASE(BillingState, 'CA', 1, 'NV', 1,'OR', 1, 'WA', 1, 0) >=1, "Pacific Standard Time", null)+ 
IF(CASE(BillingState, 'AZ', 1, 'CO', 1,'ID', 1, 'MT', 1, 'NM', 1, 'UT', 1, 'WY', 1, 0) >= 1, "Mountain Standard Time", null)+ 
IF(CASE(BillingState, 'AL', 1, 'AR', 1, 'IL', 1, 'IA', 1,'KS', 1, 'LA', 1,'MN', 1,'MS', 1,'MO', 1,'NE', 1,'ND', 1, 'OK', 1,'SD', 1,'WI', 1, 0) >= 1, "Central Standard Time", null)+ 
IF(CASE(BillingState, 'CT', 1, 'DE', 1, 'GA', 1, 'ME', 1, 'MD', 1, 'MA', 1,'MI', 1, 'NH', 1, 'NJ', 1, 'NY', 1, 'NC', 1, 'OH', 1, 'PA', 1, 'RI', 1, 'SC', 1, 'VT', 1, 'VA', 1, 'WV', 1, 0) >= 1,"Eastern Standard Time", null)+ 
IF(CASE(BillingState, 'AK', 1, 0) >=1, "Alaskan Standard Time", null)+ 
IF(CASE(BillingState, 'HI', 1, 0) >=1, "Hawaiian Standard Time", null)+ 
IF(BillingState = 'FL', IF(MID(Phone,2,3) = "850","Central Standard Time","Eastern Standard Time"),null)+ 
IF(BillingState = 'IN', IF(MID(Phone,2,3) = "219","Central Standard Time","Eastern Standard Time"),null)+ 
IF(BillingState = 'KY', IF(MID(Phone,2,3) = "270","Central Standard Time","Eastern Standard Time"),null)+ 
IF(BillingState = 'TX', IF(MID(Phone,2,3) = "915","Mountain Standard Time","Central Standard Time"),null)+ 
IF(BillingState = 'TN', IF(CASE(MID(Phone,2,3),"865",1,"423",1,0)>=1,"Eastern Standard Time", "Central Standard Time"),null)


Salesforce1 login from many devices

By default, only 5 devices can login as the same user on Salesforce1. If you login on a 6th mobile device concurrently, you will be prompted with a message indicating that 'already 5 login sessions exist.'

At that point, the 'oldest' Salesforce1 session will be logged out.

Check the below link form more information


How to enable Service Cloud User check box for multiple users in Salesforce?

UserPermissionsSupportUser is the api name for the Service Cloud Check box on the user object..

Update UserPermissionsSupportUser value to the set of users to enable Service Cloud User check box for multiple users in Salesforce.

How to enable Salesforce1 User check box for multiple users in Salesforce?

UserPermissionsMobileUser is the api name for the Salesforce1 User Check box on the user object..

Update UserPermissionsMobileUser value to the set of users to enable Salesforce1 User check box for multiple users in Salesforce.

Crypto Class in Salesforce

Provides methods for creating digests, message authentication codes, and signatures, as well as encrypting and decrypting information.

Check the below link for more information


Entity is not org-accessible in Salesforce

1. Check whether there are any typo in the code.

2. If the issues is in Apex manage sharing reason access, check the OWD of the object.


OWD of the object should be either Private or Public Read Only to access Apex Manage Sharing Reason.

Hope this helps!!

Apex Sharing Reason in Salesforce

Apex sharing reasons are used by developers when adding sharing to a record programatically. Using an apex sharing reason prevents standard users from deleting the sharing, and allows the developer to track why they added the sharing.

1. Go to an object and click New in Apex Sharing Reason related list.

2. Create New Apex Sharing Reason.



Sample Code:


How to setup Enterprise Territory Management in Salesforce?

1. Go to Enterprise Territory Management Settings.

2. Click "Enable Enterprise Territory Management".

3. Select the related records access and click Save.

4. Click "New Territory Type".

5. Save Territory Type.

6. Click "New Territory Model".

7. Save the Territory Model.

8. Click Veiw Hierarchy to create Territory.

9. Click "Create Territory".

10. Set the other stuffs.


How Does Filter-Based Opportunity Territory Assignment Work in Salesforce?

Filter-Based Opportunity Territory Assignment lets you use a simple job to assign territories to opportunities. We provide code for an Apex class that you can use as-is or modify as needed based on our guidelines. After you create and deploy the class, run the job to complete the assignment process. Job options include making assignments within date ranges and assigning territories to open opportunities only. You can also configure your settings to run the job every time an opportunity is created.

To enable Filter-Based Opportunity Territory Assignment, check the below steps

1. Go to Territory Settings.

2. Enable Filter-Based Opportunity Territory Assignment.

The Apex class code Salesforce provides assigns territories to opportunities based on a number of factors.

• Is the opportunity excluded from filter-based territory assignment? If so, no territory is assigned.

• Does the opportunity have an account assigned and does that account have a territory assigned from the active territory model? If so, the account’s territory is assigned to the opportunity. If not, no territory is assigned.

• Does the opportunity’s assigned account have multiple territories from the active model assigned? If so, the job can use a priority value from the Territory2type object or other criteria to determine which territory (if any) to assign to the opportunity.



Enterprise Territory Management allows you to organize your sales structure into separate territories, based on geographic attributes, named accounts, industry/verticals, or any other criteria that suits your organization. You can experiment with different territory models and activate the one that works best for your sales teams.

Deploying Territory Management includes these steps:

Build your territory hierarchy.
Assign users to territories and create rules for account assignment.
Preview your account assignments.
Activate your territory model.

Territory Type
Territory types help you organize your territories by key characteristics important to your company. Every territory you create must have a territory type. Territory types are used for organizing and creating territories only: they do not appear on territory model hierarchies.

Territories organize groups of accounts and the Salesforce users who work with those accounts. Territories are created based on territory types.

Territory Type Priority
Specifying and managing territory type priority information helps you choose the appropriate territory type for territories you create or edit. There are no predefined priority options, so your organization should create its own priority scheme. For example, 001 may indicate that a territory type is the highest priority or the lowest. Make sure your scheme can scale as you add more territory types.

Territory Model
A territory model represents a complete territory management system for your organization. Modeling lets you create and preview multiple territory structures and different account and user assignments before you activate the model that works best.

Territory Hierarchy
The territory hierarchy shows a model’s territory structure and serves as its main interaction point. Start from the hierarchy to create, edit, and delete territories; run assignment rules for territories, and navigate to territory detail pages for more information. From the hierarchy, you can also assign territories to opportunities, run assignment rules at the model level, and activate or archive the model.

Territory Model State
Territory model state indicates whether a territory is in the planning stage, in active use, or archived. Your organization can have only one active territory model at a time, but you can create and maintain multiple models in planning or archived state to use for additional modeling or reference


Platform Cache in Salesforce

Platform Cache is a memory layer that stores Salesforce session and org data for later access. When you use Platform Cache, your applications can run faster because they store reusable data in memory. Applications can quickly access this data; they don’t need to duplicate calculations and requests to the database on subsequent transactions. In short, think of Platform Cache as RAM for your cloud application.

With Platform Cache, you can also allocate cache space so that some apps or operations don’t steal capacity from others. You use partitions to distribute space. We’ll get to partitions later.

1. Go to Platform Cache.

2. Request Trial Capacity.

3. Create a New Platform Cache Partition.

4. Save a New Platform Cache Partition.

Sample Apex Class:

public class BusScheduleCache {
    private Cache.OrgPartition part;
    public BusScheduleCache() {
        Cache.OrgPartition orgPart = Cache.Org.getPartition('local.BusSchedule');
    public void putSchedule(String busLine, Time[] schedule) {
        // Get partition
        Cache.OrgPartition orgPart = Cache.Org.getPartition('local.BusSchedule');
        // Add cache value to the partition. Usually, the value is obtained from a callout
        orgPart.put(busLine, schedule);
    public Time[] getSchedule(String busLine) {
        Cache.OrgPartition orgPart = Cache.Org.getPartition('local.BusSchedule');
        Time[] listTimes = new Time[]{};
        Time[] listTimes1 = (Time[])orgPart.get('BusSchedule');
        if (listTimes1 == null) {
            listTimes.add(Time.newInstance(8, 0, 0, 0));
            listTimes.add(Time.newInstance(17, 0, 0, 0));
        } else {
            listTimes = listTimes1;
        return listTimes;

Salesforce User Research Program

Use the below link to join Salesforce User Research Program.


Very useful!!!


How to get data from one org to another org in Salesforce?

There are plenty of tools available to move data from one Salesforce Org to another Salesforce Org. These tools can be used for Sandbox Seeding once the sandboxes are refreshed. This avoid manual data loading.
Check the below links for the tools to get data from one org to another org in Salesforce


Direct Download - https://www.sfapex.com/download/setup.exe


I recommend SFApex tool. Awesome tool. Saves lot of time during migration. Easy to use and setup.

aura:method in Salesforce

Use <aura:method> to define a method as part of a component's API.

This enables you to directly call a method in a component’s client-side controller instead of firing and handling a component event.

Using <aura:method> simplifies the code needed for a parent component to call a method on a child component that it contains.

Sample Code:

Lightning App:

<aura:application >


Lightning Component:

<aura:component >
    <aura:method name="compMtd" action="{!c.callFromCompMetd}">
        <aura:attribute type="String" name="Str" default="testing"/>
    <ui:button label="Click" press="{!c.callBtn}"/>

Lightning Controller:

callBtn : function(component, event, helper) {
    callFromCompMetd : function(component, event, helper) {
        var params = event.getParam('arguments');
        if (params) {
            var param1 = params.Str;



Lost my contact number associated to Salesforce authenticator

Click Disconnect next to App Registration Salesforce Authenticator.


Chart Colors in Visualforce Charting

By default, chart colors match those of the built-in reporting and analytics charts so that you can create visually-consistent dashboards. If you want to create your own color scheme you can customize the colors of most chart elements.

To provide a set of color definitions to draw data series elements (bars, pie wedges, and so on), use the colorSet attribute. Set <apex:chart colorSet="..."> to specify the colors to be used for every data series in a chart. Set colorSet on a data series component to specify colors for that series only.

Sample Code:

Visualforce Page:

<apex:page controller="Sample">
    <apex:pageblock title="Members and their Years of experience" >
        <apex:chart height="250" width="350" data="{!pieData}"> 
            <apex:pieSeries tips="true" dataField="data" labelField="name" colorSet="#37241E,#94B3C8,#4D4E24,#BD8025,#816A4A,#F0E68C"/> 
            <apex:legend position="bottom"/>
    <apex:pageblock title="Members and their Years of experience" >
        <apex:chart height="250" width="350" data="{!pieData}"> 
            <apex:axis type="Numeric" position="left" fields="data" title="Years of experience"/>    
            <apex:axis type="Category" position="bottom" fields="name" title="Member"/>            
            <apex:barSeries orientation="vertical" axis="left" xField="name" yField="data" colorSet="red"/> 


Apex Controller:

public with sharing class Sample {  
    public List<PieWedgeData> getPieData() {  
        List<PieWedgeData> data = new List<PieWedgeData>();
        List<Member__c> memb = new List<Member__c>();  
        String sql = 'SELECT Name, Year_s_Of_Experience__c FROM Member__c';
        memb = Database.Query(sql);
        for(Member__c temp:memb)
            data.add(new PieWedgeData(temp.Name,temp.Year_s_Of_Experience__c));
        return data;  
    // Wrapper class  
    public class PieWedgeData 
        public String name { get; set; }  
        public Decimal data { get; set; }  
        public PieWedgeData(String name, Decimal data) 
            this.name = name;  
            this.data = data;  




Lightning Component Best Practices

1. Do not put so many console logs.

2. Make use of SLDS ( Salesforce Lightning Design System) for consistent UI design.

3. Make use of Lightning Data Services to avoid Server calls for DML operations, navigation, etc.

4. Don’t make a call to the server to filter or sort data you already have at the client-side.

5. Use Unbound expression if data across components are not required to be in Sync.

6. Before you decide to use a third-party library in a Lightning component, you should reevaluate if you really need that library. DOM manipulation libraries (like jQuery) and UI libraries (like Bootstrap or jQuery UI) in particular may no longer be needed when working with the Lightning Component Framework.

7. When possible, use the (sprite-based) Lightning Design System icons (using <lightning:icon> and <lightning:buttonIcon>) instead of custom icons.

8. Salesforce is slower for users who have debug mode enabled. So, do not enable in Production.

Check the below link for Lightning Component Best Practices from Salesforce

Events Best Practices https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_best_practices.htm?search_text=best%20practice

Best Practices for Conditional Markup - https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_conditional_markup.htm?search_text=best%20practice

Best Practices for Error Handling - https://developer.salesforce.com/blogs/2017/09/error-handling-best-practices-lightning-apex.html

Unable edit master detail field in Salesforce

Make sure "Allow reparenting" - Child records can be reparented to other parent records after they are created is enabled.

How to automate creation of sandbox in Salesforce?


Represents a sandbox.

SandboxInfo enqueues a sandbox for creation or refresh. A create operation on SandboxInfo represents creation of a new sandbox, and an update represents refresh of an existing sandbox.

For every create or update, a SandboxProcess is automatically created and is used for monitoring the sandbox copy process.

This object is available in API version 35.0 and later.

For more information, check the below link



Lightning Experience Permission

Under System Permissions, select Lightning Experience user.

This permission helps the user to access the Salesforce Lightning Experience. Users with this permission can individually enable or disable this user interface.

Lightning Challenge Salesforce

Calling all Salesforce Admins – you’re invited to participate in the first ever Admin #LightningChallenge!

Join us on a 10-day quest to learn more about Lightning and get hands-on experience with some of the cool new features and functionality.

If you successfully complete all 10 challenges, you’ll score yourself an awesome SWAG pack!

You may even be selected to be a special guest on the ButtonClick Admin Podcast.

Check the below for Salesforce Lightning Challenge.



How to create home page in Salesforce Lightning Experience?

1. Go to Lightning App Builder.

2. Click New.

3. Select Home Page.

External Data Integration Limits in Salesforce

Salesforce has External Data Integration Limits in Salesforce.

Check the below link for more information



Shield Platform Encryption for Custom Field in Salesforce


Push Notification in Service Cloud Console

1. Go to Apps.

2. Select Console App.

2. Click "Select objects and fields for notifications".

3. Click Edit and select the objects and fields related to it.

4. Choose refresh for list and record detail page.

Output in the List:


Which Fields Can I Encrypt using Shield Platform Encryption?

Encrypted Standard Fields
You can encrypt the contents of these standard field types.

On the Account object:
Account Name

On the Contact object:
Home Phone
Mailing Address (Encrypts only Mailing Street and Mailing City)
Name (Encrypts First Name, Middle Name, and Last Name)
Other Phone

On the Case object:
On Case Comments:
Body (including Internal Comments)
Encrypted Custom Fields

You can encrypt the contents of fields that belong to one these custom field types:
Text Area
Text Area (Long)

Once a custom field is encrypted, you can’t change the field type. For custom phone and email fields, you also can't change the field format.
You can't use currently or previously encrypted custom fields in custom formula fields or criteria-based sharing rules.
You can't use Schema Builder to create an encrypted custom field.

Some custom fields can’t be encrypted:
Fields that have the Unique or External ID attributes or include these attributes on previously encrypted custom fields
Fields that are used in custom formula fields
Fields on external data objects
Fields that are used in an account contact relation


How to find Text (Encrypted) usage in Salesforce?

1. Create a Force.com project in Eclipse.

2. Make sure Objects - Standard and Objects - Custom are added.

3. Search "EncryptedText" from the eclipse by pressing CTRL + H.


How to query view setup audit trail using apex in Salesforce?

Starting with Winter'16 the SetupAuditTrail object is exposed to query from Apex.

For fields in the object, check the below link


Sample SOQL:

List<SetupAuditTrail> listAudits = [SELECT Id, 
FROM SetupAuditTrail 
WHERE CreatedBy.Email LIKE '%abc.com%'];

How to enable Platform Encryption in Salesforce?

Encrypted fields are encrypted with 128-bit master keys and use the Advanced Encryption Standard (AES) algorithm.

1. Create a Permission Set with "Manage Encryption Keys Permissions Salesforce" permission.

2. Go to "Platform Encryption".

3. Click "Generate Tenant Secret".

4. Use Encrypt Files and Attachments to encrypt attachments and Encrypt Fields to encrypt the fields.



Salesforce IoT Cloud

Now you can harness the power of the Internet of Things and turn the data generated by every one of your customers, partners, devices, and sensors into meaningful action. With IoT Cloud you can process massive quantities of data, build business rules with simple, intuitive tools, and engage proactively with customers in real time.

Salesforce IoT Cloud is powered by Thunder, a scalable event processing engine, designed to ingest and analyze billions of events. Events are the data that comes from the networked devices and objects we talked about above. On top of that, Thunder lets you take personalized actions based on these events, which help your company create more enriching and focused customer experiences.

IoT Cloud’s way of taking in data and triggering actions to create experiences lets your company focus on creating engaging, individualized experiences for all your customers. These might be customized alerts, emails, or messages. Or the actions might be something else within Salesforce, like creating a service ticket, or customizing the information they access through an app.

For videos, check the below link



Transaction Security in Salesforce

Transaction Security is a feature that monitors Salesforce events in real time and applies actions and notifications based on rules you create. These rules, or policies, are applied against events in your org. (In the earlier example, our policy was to have no more than three active sessions per user.) You create policies for certain event combinations, and specify actions to take when those events occur.

1. Go to Transaction Security.

2. Enable Transaction Security Policies.

3. Create New Custom Transaction Security Policy.


Below New Custom Transaction Security Policy will send an email if any user logs in from Safari browser.

Apex class generated as part of this is below:

global class AvoidSafariBrowserPolicyCondition implements TxnSecurity.PolicyCondition {
    public boolean evaluate(TxnSecurity.Event e) {
        LoginHistory eObj = [SELECT ApiType FROM LoginHistory WHERE Id = :e.data.get('LoginHistoryId')];
        if(eObj.ApiType == 'Safari') {
            return true;
        return false; 

Steps to be followed for Per User Identity type while setting External Data Source in Salesforce

1. Go to the Profile or the Permission Set used for Files Connect permission.

2. Add the External Data Source to the profile/permission set.

3. Go to Authentication Settings for External Systems and authenticate yourself.


Lightning Connect in Salesforce not available

Lightning Connect in Salesforce not available, then contact Salesforce.com support to enable it.

If you are in a Developer Edition, then it will show up.

If you are in a sandbox or in a production instance, you will need to reach out to Salesforce.com support team and purchase lightning connect license in order to use it.


How to know Salesforce server instance?

1. Go to Company Information.

2. See Instance.


1. Go to "https://status.salesforce.com/status".

2. Click "My Domain" in the right top corner.

3. Enter the domain name and click "Search".

For more information, check the below link