Login Hours in Salesforce

Login Hours is used to restrict users to avoid logging into Salesforce during Non-Login hours. We can specify the timing for each day during which the users are allowed to login.

Note:
Depending on whether you’re viewing or editing login hours, the hours can be different. On the Login Hours edit page, hours appear in your specified time zone. On the profile overview page, hours appear in the org’s original default time zone.
 
What happens when the Login Hours end for an Active Session for a user?
If users are logged in when their login hours end, they can continue to view their current page, but they can’t take any further action.     
Reference Article:  

Time-Based action in Salesforce Flow

1. Go to Flows in Setup.

2. Click New Flow.

3. Select 'Record-Triggered Flow'.


4. Select the Object, Criteria, etc..


5. Click "Add Scheduled Paths (Optional)".


6. Select the Time Source. Set Offset Number and Offset Options.


7. Click Add Element. Select Update Records. Set the field to update.


Flow:
 

Output:
 
 


How to find users using Data Loader in Salesforce?

 LoginHistory entity can be used to find whether users are using Data Loader.

The Application column/field in the LoginHistory entity will be one of the following when logged in from Data loader.

DataLoaderPartnerUI/
DataLoaderPartnerBatch/
DataLoaderBulkUI/
DataLoaderBulkBatch/

Note:
The Application column/field is not allowed in filter. So, export the data and do check it.
 
Sample SOQL:
SELECT UserId, LoginTime, Application, LoginType, APIType, APIVersion FROM LoginHistory
WHERE LoginTime = TODAY AND LoginType = 'Partner Product'

 
Output: 
 

Owner Id in JUNCTIONIDLIST() in Salesforce

Error: Formula result is data type (JUNCTIONIDLIST(Ids)), incompatible with expected data type (null).
 

Case.OwnerId or Lead.OwnerId is not supported as it can refer to Queue also. So, use Case.Owner:User.Id and Lead.Owner:User.Id to avoid this issue.


Geolocation field display using getRecord() in Salesforce using Lightning Web Component(LWC)

Geolocation Field:
 

Sample code:
HTML:
<template>
    <lightning-card>
        <b>Account Geo Location information:</b><br/>
        Latitude is {latitude}<br/>
        Longitude is {longitude}
    </lightning-card>
</template>

JavaScript:
import { LightningElement, api, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
const FIELD_Latitude ='Account.Geo_Location__Latitude__s';
const FIELD_Longitude ='Account.Geo_Location__Longitude__s';
const FIELDS = [ FIELD_Latitude, FIELD_Longitude ];

export default class GeoLocationGetRecord extends LightningElement {

    @api recordId;
    account;
    longitude;
    latitude;

    @wire( getRecord, { recordId: '$recordId', fields: FIELDS } )
    wiredRecord({ error, data }) {

        if ( error ) {

            let message = 'Unknown error';
            if ( Array.isArray( error.body ) ) {
                message = error.body.map(e => e.message).join( ', ' );
            } else if ( typeof error.body.message === 'string' ) {
                message = error.body.message;
            }
            this.dispatchEvent(
                new ShowToastEvent( {
                    title: 'Error loading Account',
                    message,
                    variant: 'error',
                } ),
            );

        } else if ( data ) {

            this.account = data;
            console.log( 'Account is ' + JSON.stringify( this.account ) );
            this.longitude = this.account.fields.Geo_Location__Longitude__s.value;
            this.latitude = this.account.fields.Geo_Location__Latitude__s.value;

        }
    }

}

JS-meta.xml:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <isExposed>true</isExposed>    <targets>
        <target>lightning__RecordPage</target>
    </targets>
</LightningComponentBundle>

 
Output:
 

How to run SOQL using Salesforce REST API with WHERE Condition?

Sample Endpoint:
https://infallibletechie-b-dev-ed.my.salesforce.com/services/data/v53.0/query/?q=SELECT+Id,Name,Type,Industry+FROM+Account+WHERE+Name=%27InfallibleTechie%27


Salesforce Omni-Channel Supervisor Configuration

1. Create a Public Group.

2. Assign Users to the Public Group.

3. Go to Supervisor Configurations under Setup.


4. Click New.

5. Enter the Details. 

6. Select the Supervisor Profiles.

7. In "Define Visible Agents" section, select the Public Group.


Note:
Supervisors can see only the information of the users from the Public Group when they access Omni-Supervisor tab.

New Task and New Event with Record Type Selection in Salesforce Lightning Experience

Record Page Settings helps us to decide how to configure New Task and New Event with Record Type selection.


Note:
If Einstein Activity Captured in your org, then by default the Record Page Setting will be Related List.

For "Activity Timeline" Setup:
1. Add Related List - Single to the Lightning Record Page.

2. Select "Open Activities" as the related list.



For "Related Lists" Setup:
Add Open Activities to the Related List.



Overflow Assignee in Salesforce Routing Configuration

We can select User or Queue for Overflow Assignee.
Omni-Channel routes the items to it when your org reaches Omni-Channel limits.


Omni-Channel Limits:
 

Asynchronous Processes in Salesforce

The maximum number of Asynchronous Processes per a 24-hour period is 250,000 or the number of user licenses in your organization multiplied by 200, whichever is greater.

Asynchronous Apex: Batch Apex, Queueable Apex, scheduled Apex, and future methods.

Sample Code to check the limit:
Map < String,System.OrgLimit > limitsMap = OrgLimits.getMap();
System.OrgLimit apiRequestsLimit = limitsMap.get( 'DailyAsyncApexExecutions' );
System.debug( 'Limit Name: ' + apiRequestsLimit.getName() );
System.debug( 'Usage Value: ' + apiRequestsLimit.getValue() );
System.debug( 'Maximum Limit: ' + apiRequestsLimit.getLimit() );
 
Output:

With Sharing keyword for Restriction Rule in Salesforce

 If "With Sharing" keyword is used in the Apex Class, then the SOQL won't run in System Mode. It will run in User Mode and respect the Restriction Rules configured.
 
Custom Field in User Object for User Criteria:
 

Custom Field in the Custom Object for Record Criteria:
 

Restriction Rule on the Custom Object:
 
 

Sample Code:
 
Visualforce Page:
<apex:page controller="EmployeesDataController">
    <apex:pageBlock>
        <apex:pageBlockTable value="{!listEmployees}" var="emp">
            <apex:column>{!emp.Name}</apex:column>
            <apex:column>{!emp.Age__c}</apex:column>
            <apex:column>{!emp.Above_18__c}</apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

Apex Class:
public with sharing class EmployeesDataController {
    
    public List < Employee__c > listEmployees { get; set; }
    
    public EmployeesDataController() {
        
        listEmployees = new List < Employee__c >();
        listEmployees = [ SELECT Id, Name, Age__c, Above_18__c FROM Employee__c LIMIT 100 ];
        
    }

}

 
Output:
 

 Note:
If "with sharing" keyword is removed, the SOQL will run in System Mode and return all the data. It won't obey the Restriction Rule.

Average Wait Time in Salesforce Omni-Channel Supervisor using Apex

Sample Code:
Integer i = 0;
Long total = 0;
for ( LiveChatTranscript chat : [ SELECT Id, CreatedDate, RequestTime FROM LiveChatTranscript WHERE OwnerID = '00G5f000000aT2F' ] ){
    
    i += 1;
    total += ( system.now().getTime() - chat.RequestTime.getTime() );
    
}
Long seconds = total / ( i * 1000 );
System.debug( 'Average is ' + ( seconds / 60 ) + ' minutes and ' + math.mod( seconds, 60 ) + ' Seconds' );

How to query(SOQL) to fetch Reports in Salesforce?

Sample SOQL:
SELECT Name, Format, LastRunDate, LastViewedDate, LastModifiedDate, CreatedDate FROM Report
 
Output:
 
SOQL to find reports that last ran last year:
SELECT Name, Format, LastRunDate, LastViewedDate, LastModifiedDate, CreatedDate
FROM Report
WHERE LastRunDate = LAST_YEAR

Features that are available in Salesforce Service Setup and not in Standard Setup

1.Service Setup has all Service related setup and it will be easy for Service Cloud Developers/Admins to access it. Whereas, the Standard Setup shows all the setups. So, it makes the setup feature search easy.
 
2. Recommended Setup is available.

 
If we click "View All", it will display all Service Cloud related features. We can easily set it up from it guidance.
 

3. Service Cloud metrics is available.


How to display PDF File from Static Resource using Lightning Web Component(LWC) in Salesforce?

Sample Code:
HTML:
<template>
    <iframe src={SamplePDFURL} height="100%" width="100%"></iframe>
</template>

JavaScript:
import { LightningElement } from 'lwc';
import SamplePDF from '@salesforce/resourceUrl/SamplePDF';

export default class ShowPdfFile extends LightningElement {

    SamplePDFURL = SamplePDF;

}

JS-meta.xml:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__Tab</target>
    </targets>
</LightningComponentBundle>
 
Static Resource:
 
 
Output: 
 

Unable to Edit Messaging Channel in Salesforce Setup


1. Add "Messaging User" to the user's Permission Set License Assignments.



2. Check whether the user has "Configure Messaging" permission via profile or permission set.


How to hide Setup menu for users in Salesforce?

Disable “View Setup and Configuration” permission from the user’s profile to hide Setup menu for users in Salesforce. 
 
 

How to find reports that are part of a Dashboard in Salesforce?

Sample SOQL:
SELECT Name, DeveloperName
FROM Report
WHERE Id IN ( SELECT CustomReportId FROM DashboardComponent WHERE DashboardId = '01Z5f000000VAB9EAO' )

Output:

What are set up and non set up Objects in Salesforce?

Non-Setup Objects:
Non-Setup objects are standard objects like Account or any custom object.
 
Setup Objects:
Setup Objects are used to interact with metadata for declarative development. Setup objects are Group1, GroupMember, QueueSObject, User, UserRole, UserTerritory, Territory, etc..
List of Setup objects can be found in the following link
 
Note: 
We cannot do DML operations on Setup and Non-Setup objects in the same transaction. We will hit the "MIXED_DML_OPERATION" exception.

Sample Salesforce lightning/uiRecordApi to fetch data in Lightning Web Component without Apex

Sample Code:
HTML:
<template>
    <lightning-card>
        Account Name: {name}<br/>
        Website: {website}
    </lightning-card>
</template>

JavaScript:
import { LightningElement, api, wire } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { getRecord } from 'lightning/uiRecordApi';

const FIELDS = [ 'Account.Name', 'Account.Website' ];

export default class AccountQuickView extends LightningElement {

    @api recordId;
    accountRec;
    name;
    website;

    @wire(getRecord, { recordId: '$recordId', fields: FIELDS } )
    wiredRecord( { error, data } ) {

        if (error) {

            let message = 'Unknown error';
            if ( Array.isArray( error.body ) ) {

                message = error.body.map(e => e.message).join( ', ' );

            } else if (typeof error.body.message === 'string' ) {

                message = error.body.message;

            }
            this.dispatchEvent(
                new ShowToastEvent( {
                    title: 'Error loading account',
                    message,
                    variant: 'error',
                } ),
            );
        } else if ( data ) {

            this.accountRec = data;
            this.name = this.accountRec.fields.Name.value;
            this.website = this.accountRec.fields.Website.value;

        }

    }

}

js-meta.xml:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <isExposed>true</isExposed>    <targets>
        <target>lightning__RecordPage</target>
    </targets>
</LightningComponentBundle>

 
Output: 
 

Unknown Property Error in Salesforce VisualForce Page

In Visualforce, getter and setter are mandatory to reference variables from the custom controller or extension apex class.
 
1. Declare the variable with public scope.

2. User getter and setter.

Sample code:
 
public class ClassName() {

     public String strVar { get; set; }

    public ClassName() {

       strVar = 'Default Value';

    }

}

How to check Opportunities Closed every month in Salesforce report?

1. Create a Report on Opportunities object.

2. Filter it based on Close Date.

3. Group By the report using the Close Date.

4. By Default, the Close Date Grouping will be done by the Date. So, change it to Calendar Month.


Output:
 

How to lock record from editing when a check box is set to true in Salesforce?

Sample Validation Rule:
AND(
Is_Active__c,
NOT( ISCHANGED( Is_Active__c ) ),
NOT(ISNEW())
)

Output:
 

Salesforce Formula to check whether date is within last 15 days

Sample formula:
AND (
Date__c <=TODAY(),
Date__c >= ( TODAY() - 15 )
)

Output:

Salesforce Chat Blocked Status


Chat status will be set to Blocked if the agent blocked the visitor.


Check the "Chat Transcript Events" to verify it.