How to query all the list views for an object in Salesforce?

Sample SOQL:
SELECT Id, Name, DeveloperName, SobjectType FROM ListView WHERE SobjectType = 'Employee__c'

Here Employee__c is a custom object.

Queue not working for Salesforce Chat

Issue may be due to the Capacity values entered.
1. Check the Queue Capacity entered in the Chat Button.
2. Then, check Capacity in Routing Configuration.

 As per the above configuration, for each agent, 2 chats can be queued.

How to open records as sub tab from Visualforce in Salesforce Lightning?

Sample Code:
<apex:page standardController="Account">
    <apex:includeScript value="/support/console/51.0/integration.js"/>
    <script type="text/javascript">
        var recordIdForSubTab;
        var recordNameForSubTab;
        function openAsSubTab( recId, recName ) {
            recordIdForSubTab = recId;
            recordNameForSubTab = recName;
            sforce.console.getEnclosingPrimaryTabId( openSubtab );
        var openSubtab = function openSubtab( result ) {
            var primaryTabId =;
            sforce.console.openSubtab( primaryTabId , '/' + recordIdForSubTab, false,
                recordNameForSubTab, null, openSuccess, 'salesforceSubtab' );
        var openSuccess = function openSuccess( result ) {
            if (result.success == true) {
                alert( 'Subtab successfully opened' );
            } else {
                alert( 'Subtab cannot be opened ' + JSON.stringify( result ) );
     <apex:pageBlock >
        <apex:pageblockTable value="{!Account.Contacts}" var="con">
            <apex:column value="{!con.Name}"/>
            <apex:column ><apex:outputLink onclick="openAsSubTab( '{!con.Id}', '{!con.Name}' );">Open As Sub Tab</apex:outputLink></apex:column>


New Event or New Task actions are missing for users in Salesforce

If New Event or New Task actions are missing for users in Salesforce, then make sure the user's profile have Edit Tasks and Edit Events Permissions.

If these permissions are enabled and still not visible, then check the record types.

Salesforce Experience Builder/Community Builder

Experience Builder and site templates let you create, brand, and publish a custom site that looks great on any mobile device! Choose a template to quickly start your site, and then style the pages to match your company’s branding.

When you create an Experience Cloud site, you can create an Experience Builder or a Salesforce Tabs + Visualforce site.

To change template for an existing Community, check -

How to Change template for Experience Site/Community in Salesforce?

1. Go to Administration.

2. Select Settings.

3. Click Change Template.

Changing your site’s template permanently deletes all your pages. We're just making sure that's what you want.

How to add/modify tabs in Salesforce Experience Site/Community for Salesforce Tabs + Visualforce

 1. Go to Administration.

2. Select Tabs and add/remove Tabs.


How to update fields displayed in Related List in Salesforce?

1. Open the page layout. 

2. Select Related Lists.

3. Click the gear icon(Related List Properties) to update the fields.

How to show the Report Chart on the record detail page and filter the report using currently viewing record in Salesforce?

In the below example, I have used standard objects Account and Opportunity.
Parent Object - Account
Child Object - Opportunity
Report Grouped by Account Name:

Summarized by Amount Field:

Save the Report in Public Reports Folder:

After saving the report, use Add Chart button to add the Chart:

Create a section in the page layout

Select Report Charts and add the report chart

Adjust the report using the properties:


How to make field non-editable in Salesforce?

For all the users:
1. Go to the page layout.

2. Click the Field Properties in the page layout.

3. Make it Read-Only.

For Specific profile
1.  Open the field.

2. Click Set Field-Level Security button.

3. Select Read-Only check box for the profile.

Field to be updated only by the Owner:

Events Tab in Salesforce Lightning

1. Go to Calendar Tab.

2. Select Table.

Salesforce Find and Create Records Pre-Chat API with Contact object picklist field

Chat Deployment: 
Visualforce Page:
<apex:page showHeader="false" standardStylesheets="false" sidebar="false" title="Pre-Chat Form" cache="false">

    <!-- form id should be used in getElementById() -->
    <script type="text/javascript">
        (function() {
            function handlePageLoad() {
                var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)");
            if (window.addEventListener) {
                window.addEventListener('load', handlePageLoad, false);
            } else {
                window.attachEvent('onload', handlePageLoad, false);

    <form method='post' id='prechatForm'>
        <table cellspacing="5" cellpadding="5">
                <td>First Name</td>
                <td><input type='text' name='liveagent.prechat:ContactFirstName' /></td>
                <td>Last Name</td>
                <td><input type='text' name='liveagent.prechat:ContactLastName' /></td>
                <td><input type='text' name='liveagent.prechat:ContactEmail' /></td>
                <td>Contact Level</td>
                    <select name="liveagent.prechat:ContactLevel">
                        <option value="">--None--</option>
                        <option value="Primary">Primary</option>
                        <option value="Secondary">Secondary</option>
                        <option value="Tertiary">Tertiary</option>

                <td><input type='text' name='liveagent.prechat:CaseSubject' /></td>
        <!-- Contact creation Start -->
        <input type="hidden" name="" value="FirstName,ContactFirstName;LastName,ContactLastName;Email,ContactEmail;Level__c,ContactLevel" />
        <input type="hidden" name="" value="FirstName,true;LastName,true;Email,true" />
        <input type="hidden" name="" value="FirstName,true;LastName,true;Email,true" />
        <input type="hidden" name="" value="FirstName,true;LastName,true;Email,true;Level__c,true" />
        <!-- Contact creation End -->
        <!-- Case creation Start -->
        <!-- Setting Case Status and Origin -->
        <input type="hidden" name="liveagent.prechat:CaseStatus" value="New" /><br />
        <input type="hidden" name="liveagent.prechat:CaseOrigin" value="Chat" /><br />
        <input type="hidden" name="" value="Subject,CaseSubject;Status,CaseStatus;Origin,CaseOrigin" />
        <input type="hidden" name="" value="Subject,true;Status,true;Origin,true" />
        <!-- Case creation End -->
        <!-- Linking Contact and Case to the Chat Transcript -->
        <input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Contact" value="ContactId" />
        <input type="hidden" name="liveagent.prechat.findorcreate.saveToTranscript:Case" value="CaseId" />
        <!-- Showing the Contact and Case when the Chat loads automatically in a subtab in the Salesforce console -->
        <input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Contact" value="true" />
        <input type="hidden" name="liveagent.prechat.findorcreate.showOnCreate:Case" value="true" />
        <!-- Linking Case to the Contact -->
        <input type="hidden" name="liveagent.prechat.findorcreate.linkToEntity:Contact" value="Case,ContactId" />
        <input type="submit" value="Submit"/>


Chat Button:


Make sure the VF page is added to the Site's Guest Profile Access.


Age calculation using LWC in Salesforce

Sample Code:

            label="Enter a date"
        Age is {age}

import { LightningElement } from 'lwc';
export default class SampleLWC extends LightningElement {


    handleChange( event ) {

        console.log( event.detail.value );
        let d1 = new Date( event.detail.value );
        let d2 = new Date();

        let varAge = d2.getYear() - d1.getYear();
        console.log( varAge );

        if ( d1.getUTCMonth() < d2.getUTCMonth() ) {
            console.log( 'Month' );

        }else if ( d1.getUTCMonth() === d2.getUTCMonth() ) {
            console.log( 'Day' );
            console.log( d1.getUTCDate() );
            console.log( d2.getUTCDate() );
            if ( d1.getUTCDate() < d2.getUTCDate() )

        this.age = varAge;   


<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="">


Customized download error: Sfc.ContentDownloadHandlerFactory implementation contains call to download operation in Salesforce

Customized download error
Sfc.ContentDownloadHandlerFactory implementation contains call to download operation
Above exception happens when VersionData is queried inside an Apex Class where Sfc.ContentDownloadHandlerFactory interface is used. 
To resolve the issue, avoid querying VersionData inside an Apex Class where Sfc.ContentDownloadHandlerFactory interface is used.
Querying VersionData isn't allowed from Download Handler. If a custom Apex download handler is active, this field is accessed from the API, and the download is not allowed, Salesforce will return a CONTENT_CUSTOMIZED_DOWNLOAD_EXCEPTION error. Reference Article -

How to call apex class when a file is downloaded in Salesforce?

Use Sfc.ContentDownloadHandlerFactory interface to call apex class when a file is downloaded in Salesforce.
Sample Code:
public class ContentDownloadHandlerFactoryImpl implements Sfc.ContentDownloadHandlerFactory {

    public Sfc.ContentDownloadHandler getContentDownloadHandler( List<ID> listIds, Sfc.ContentDownloadContext context ) {
        Sfc.ContentDownloadHandler contentDownloadHandler = new Sfc.ContentDownloadHandler();
        /* To Prevent downloading it from Mobile */
        if ( context == Sfc.ContentDownloadContext.MOBILE ) {
            contentDownloadHandler.isDownloadAllowed = false;
            contentDownloadHandler.downloadErrorMessage = 'Downloading a file from a mobile device is not allowed.';
            return contentDownloadHandler;
        contentDownloadHandler.isDownloadAllowed = true;
        return contentDownloadHandler;

When a download is triggered either from the UI, Connect API, or an sObject call retrieving ContentVersion.VersionData, implementations of the Sfc.ContentDownloadHandlerFactory are looked up.
System.debug( 'Value is ' + [ SELECT Id, VersionData FROM ContentVersion WHERE Id = '0684x00000377ZUAAY' ] ); 
If the above code is executed, then also the apex class will be called.
But, if we use the below REST API Endpoint, then the apex class won't be invoked.

How to avoid/prevent creating Lead if Contact exist in Salesforce?

1. Create Contact Matching Rule.
2. Create Lead Duplicate Rule. Use the Contact Matching Rule.


How to create a Variable in MS Power Automate?

Use Initialize Variable to create Variable in MS Power Automate. Don't use Set Variable. Set Variable is used to assign values to the existing initialized variable.

Salesforce Resources in Events

Use a resource calendar to schedule the use of a shared resource, such as a conference room or an overhead projector.
1. Go to Public Calendars and Resources in Setup.
2.  Create Resources.


Two Events cannot have the same resource at the same time:

Using LWC for Quick Action in Salesforce

Sample LWC:

import { LightningElement, api } from 'lwc';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import DESCRIPTION_FIELD from '@salesforce/schema/Account.Description';
import ID_FIELD from '@salesforce/schema/Account.Id';

export default class QuickActionComponent extends LightningElement {

    @api recordId;

    @api invoke() {

        console.log( "Inside Invoke Method" );
        console.log( "Record Id is " + this.recordId );

        const fields = {};
        fields[ ID_FIELD.fieldApiName ] = this.recordId;
        fields[ DESCRIPTION_FIELD.fieldApiName] = 'Testing LWC Quick Action';

        const recordInput = {fields};

        updateRecord( recordInput )
        .then( () => {
                new ShowToastEvent( {
                    title: 'Success',
                    message: 'Account updated',
                    variant: 'success'
                } )
        }).catch( error => {
                new ShowToastEvent( {
                    title: 'Error updating or reloading record',
                    message: error.body.message,
                    variant: 'error'
                } )



<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="">
        <targetConfig targets="lightning__RecordAction">


Salesforce Summer ’21 Release

New Omni-Channel Capacity
The status-based capacity limit increased to a maximum of 100 simultaneous work items per agent. Increasing status-based capacity facilitates long-term planning for high-volume support teams.
Previously, an agent can be assigned a total of 40 work items.

The tab-based capacity limit permits agents a maximum of 100 tabs at once, which improves system performance and avoids agents owning near infinite numbers of work items.

Send Customers Pictures, Audio, and Video From Toll-Free Numbers
Now agents can send multimedia messages to support customers in new ways.

Identify and Match Event Messages with the EventUuid Field
Platform event messages now include the EventUuid field, which identifies an event message and is available in subscribers using API version 52.0 and later. Use this field to match published and received event messages by comparing the UUIDs of the received events with those returned in the SaveResult of publish calls. This way, you can find any event messages that aren’t delivered and republish them.

Using LWC for Quick Action in Salesforce
Inline Editing in Salesforce Reports (Beta) 
With inline editing, you can update certain types of text, numeric, and checkbox fields without leaving the Report Run page. For example, Sales reps can run an opportunity report and review and update the opportunity amounts in one place.

Event Notification from Salesforce Event Relation Change Event in Lightning

 1. Enable Change Data Capture for Event Relation.

2. Create an Organization-Wide-Email Address.

3. Create the below trigger.

trigger EventRelationChangeEventTrigger on EventRelationChangeEvent ( after insert ) {

    Map < Id, Set < Id > > mapEventIdAttendees = new Map < Id, Set < Id > >();
    List < Messaging.SingleEmailMessage > listMsgs = new List < Messaging.SingleEmailMessage > ();
    for ( EventRelationChangeEvent objERCE : ) {  
        EventBus.ChangeEventHeader header = objERCE.ChangeEventHeader;
        system.debug( 'Change Type ' + header.changetype );
        if ( header.changetype == 'CREATE' ) {         
            if ( !mapEventIdAttendees.containsKey( objERCE.EventId ) )
                mapEventIdAttendees.put( objERCE.EventId, new Set < Id >() );
             mapEventIdAttendees.get( objERCE.EventId ).add( objERCE.RelationId );
    if ( mapEventIdAttendees.size() > 0 ) {
        for ( Event objEvent : [ SELECT Id, Subject, Description, StartDateTime, EndDateTime  FROM Event WHERE Id IN: mapEventIdAttendees.keySet() ] ) {
            for ( Id attendeeId : mapEventIdAttendees.get( objEvent.Id ) ) {
                Messaging.SingleEmailMessage msg = new Messaging.SingleEmailMessage();
                String strBody = '<b>Event Details:</b><br/>';
                strBody += 'Start Date and Time: ' + objEvent.StartDateTime + ' GMT <br/>';
                strBody += 'End Date and Time: ' + objEvent.EndDateTime + ' GMT <br/>';
                strBody += 'Additional Information: ' + objEvent.Description;
                msg.setSubject( objEvent.Subject );
                msg.setHTMLBody( strBody );
                msg.setTargetObjectId( attendeeId );  
                msg.setSaveAsActivity( false );
                msg.setOrgWideEmailAddressId( '0D24x000000kAqp' );
                listMsgs.add( msg );  
        if ( listMsgs.size() > 0 )
            Messaging.sendEmail( listMsgs );


Sample Email:

Salesforce Lightning Scheduler

Salesforce Lightning Scheduler helps customers and prospects in scheduling appointments with the right person in the Organization at the right time and location. Lightning Scheduler can be used to quickly set up appointments within standard objects like leads, opportunities, and accounts.
1. Create Service Territory.
2. Create Service Resource.
3. Create Work Type Group.
4. Create Work Type.
5. Assign the Work Type to Work Type Group.
6. Enable Maps and Location under setup.
7. Add Schedule Appointment quick action to the page layout.

Salesforce Event Notification

Event invitee email notifications are only sent from Salesforce when you Invite People to an Event and Schedule Resources in Salesforce Classic.

It is not possible to send Event attendees email notifications in Lightning without setting up and configuring Einstein Activity Capture (EAC) for your organization.

Help Article -
1. Create Event record in Salesforce classic.
2. Click Add Attendees to add Contacts, Users and Leads.

3. Click Save and Update button.

Organizer Email Notification:


Attendee Email Notification:


Notes in Salesforce Case

1. Go to Notes Settings.

2. Enable Notes.

3. Add the Notes related list in the page layout.