How to find cases for which you are part of Case Teams for it in Salesforce?

1. Create a List View.

2. In the filter select "My case teams".


My case teams will pull cases that you are part via Case Team. Even if you are the owner of Case record, it won't pull. You should be added as part of Case Team to pull while using My case teams filter.


If the Admin User uses the list view with My case teams as the filter, then this Test 1 Case will be displayed as the Admin User is added to Case Team as an Auditor.

How to avoid hard coding queue id in Salesforce Flow?

Custom Labels can be used to avoid hard coding queue id in Salesforce Flow.

Sample Custom Label:
 
Referencing Custom Label in Salesforce Flow Get Records Element:
 

 

How to troubleshoot agents capacity and available for Salesforce Omni-Channel?

1. Find the CreatedDate of the Chat Transcript record.

SELECT CreatedDate
FROM LiveChatTranscript
WHERE Id = '5708c000005VqSAAA0'

CreatedDate is 2022-04-29T02:42:52

2. Find when the agents from the queue changed their Omni-Channel Status. 
Note:
Adjust the date in the SOQL filter. In the following, I am checking from 42 mins before the chat was requested.

SELECT Id, Name, ServicePresenceStatus.DeveloperName, CreatedDate, UserId
FROM UserServicePresence
WHERE CreatedDate >= 2022-04-29T02:00:00Z AND CreatedDate <= 2022-04-29T02:42:52Z
AND UserId IN (
SELECT UserOrGroupId
FROM GroupMember
WHERE GroupId = '00G8c000006GQI1'
)
ORDER BY CreatedDate ASC

00G8c000006GQI1 is the Queue Id.

0058c000007oEERAA2 was online at 2022-04-29T02:41:36

 
3. Check the agent's capacity. 
Note:
Adjust the date in the SOQL filter.

SELECT Id, RequestDateTime, AcceptDateTime, AssignedDateTime, CloseDateTime, DeclineDateTime, OriginalGroupId, PendingServiceRoutingId, UserId, User.Name, WorkItemId, AgentCapacityWhenDeclined, CapacityPercentage, CapacityWeight
FROM AgentWork
WHERE UserId = '0058c000007oEERAA2'
AND CreatedDate >= 2022-04-29T02:00:00Z AND CreatedDate <= 2022-04-29T02:50:52Z

System.CalloutException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target Exception in Salesforce

"System.CalloutException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target" Exception in Salesforce occurs when the endpoint has certificate issue.

Reach out to the Endpoint URL supporting team to resolve the Certificate issue since the issue is from Certificate configuration. Once the certificate issue is resolved, wait for sometime and test it.

There are free SSL checkers webesites. You can utilize them if your employer/organization allows using it to check the certificate issues.

Portal account owner must have a role Exception in Salesforce

There are two possibilities for this issue:

1. Running user for creating Account, Contact and User for Experience Cloud site access doesn't have a Role.

To fix this issue, assign a Role to the running user.

Reference Article:

2. Creating User for an Experience Cloud site and the account owner of the Contact is not having a Role.

To fix this issue, assign a Role to the Account owner of the Contact record from which the User is getting created.

How to set CreatedDate and LastModifiedDate while inserting Data using Data Loader in Salesforce?

1. Go to User Interface in Salesforce Setup.


2. Enable the check box Enable "Set Audit Fields upon Record Creation" and "Update Records with Inactive Owners" User Permissions.


3. Create a Permission Set with "Set Audit Fields upon Record Creation" permission enabled.


4. Assign the Permission Set to the Data loading User.

5. In the import csv file, use CreatedDate and LastModifiedDate.

Sample CSV for Chat Transcript Object:
LiveChatVisitorId,Status,EndedBy,CreatedDate,LastModifiedDate
5718c000003xBvlAAE,Completed,Agent,2022-04-20T15:30:00.000+0000,2022-04-20T15:30:00.000+0000

Data Loader Field Mapping:
 
 

How to find part of the day Morning, Afternoon and Evening using Salesforce Formula

Sample Formula for Easter Standard Timezone(GMT or UTC - 4):
IF( HOUR(TIMEVALUE( CreatedDate - 4/24 ) ) < 12, "Morning",
IF( HOUR(TIMEVALUE( CreatedDate - 4/24 )) < 16, "Afternoon", "Evening" ) )

Output:
 
 
If the time is less than 12 PM, it will show as Morning.
If the time is greater than or equal to 12 but less than 16(4 PM), it will show as Afternoon.
If the time is greater than or equal to 18, it will show as Evening.

How to do documentation in Salesforce Flow Development?

Use Description field to document Salesforce Flow Development. This will make easier for yourself and other developers, admins and architects when they look at it. Share the purpose of the element and it's basis functionality.

Screen Element:


 
Get Records Element:

 
Also, use meaningful names for the Flow elements.

Salesforce Chat Button Availability using REST API

https://hostname/chat/rest/Visitor/Availability can used to find whether a Chat Button is available to receive new incoming Chat Requests in Salesforce.

1. Go to Chat Settings in Salesforce Setup.

2. Copy the "Chat API Endpoint" URL.

Add Visitor/Availability to the end of the URL.
Example:
https://d.la5-c2-ia5.salesforceliveagent.com/chat/rest/Visitor/Availability

3. Do a GET Call to find the availability.

https://d.la5-c2-ia5.salesforceliveagent.com/chat/rest/Visitor/Availability?org_id=00D8c0000015heN&deployment_id=5728c000000QUAz&Availability.ids=5738c000000QVxa
 
Example:


Header:
 
 

Report on Decline Requests in Salesforce Omni-Channel

Sample Presence Decline Reasons:


To report on Agents Decline Reasons, use the following steps.

1. Create a Custom Report Type on Agent Work object.


2. Create a Report using the customer report type created in Step 1.


Video Reference:



How to allow Agents to Decline Requests in Salesforce Omni-Channel?


Follow the below steps to allow Agents to Decline Requests in Salesforce Omni-Channel.

1. Go to Presence Decline Reasons in Salesforce Setup.


2. Add Presence Decline Reasons.


3. Go to the Agent's Presence Configuration and enable "Allow Agents to Decline Requests" and "Allow Agents to Choose a Decline Reason".


Video Reference:

How to allow agents to decline requ... x
How to allow agents to decline requests in Salesforce Omni Channel

How to display list of records retrieved from Flow in Salesforce Einstein Bot?

Sample Flow:
 
 

 
Sample Einstein Bot:
 

 
Output:
 

Salesforce Einstein BOT is displaying/showing Variable API Name instead of it's value

Salesforce Einstein BOT will display the API Name of the Variable whenever the value is null or blank.

1. Do a null check before displaying the variable to the customers.

2. Use Custom Chatbot User.


Make sure the Custom Chatbot user profile have access to the objects, fields, Apex Classes, etc.

How to delete Chat Session Records in Salesforce?

Chat Session records are stored in LiveAgentSession entity.

Following Sample code can be used to delete the Chat Session records permanently(hard delete).

Sample Code:
List < LiveAgentSession > listLiveAgentSessions = [ SELECT Id FROM LiveAgentSession ];
if ( listLiveAgentSessions.size() > 0 ) {
  delete listLiveAgentSessions;
  Database.emptyRecycleBin( listLiveAgentSessions );
}

SOQL:
SELECT Id, AgentId, LoginTime, LogoutTime
FROM LiveAgentSession 
 

The above SOQL can be used to Query Chat Session(LiveAgentSession) records.

Common scenarios of Apex Trigger in Salesforce

For Common scenarios for Apex Trigger in Salesforce, check the following

1. How to avoid closing Parent Case when child(related) cases are still open in Salesforce?
 
2. How to update parent records when task is created or updated?
 
3. Trigger to find Case assigned date and time in Salesforce

4. How to update child records when parent record is updated in Salesforce?
 
5. How to track more than 20 fields values in Salesforce?
 
6. Trigger to send a pdf along with email in Salesforce

7. Trigger to capture Deactivation of User date
 
8. Trigger to count number of Contacts associated with an Account
 
9. Trigger to store case's previous status in Salesforce  
 
10. Trigger to restrict attachment Size restriction in Salesforce

Salesforce Einstein BOT Backup Rule

Salesforce Einstein BOT Backup Rule will be triggered when the action doesn't result in any choices to display to your customer. 

Please check the following simple implementation:

Sample Backup Rule Setup:


Sample Backup Dialog:


Output:
When Choices were Available:


When Choices weren't Available:


Assigned Work in Salesforce Omni-Supervisor does not capture or display any information


"Assigned Work" tab is used to display the work items that are making their way through your queues.
Reference Article:
https://help.salesforce.com/s/articleView?id=sf.omnichannel_supervisor_work_tab.htm&type=5

If skills-based routing rules on a routing configuration is enabled, and assign the routing configuration to a queue, the queue's membership no longer applies to the routing. The work will be routed based on Skills and not based on Queue Membership.
Reference Article:
https://help.salesforce.com/s/articleView?id=sf.omnichannel_skills_based_routing_comparison_to_queues.htm&type=5
 

So, if you are using Skill-Based routing, it won't appear in "Assigned Work" tab. If you are using Omni-Flow and route via Skills, then also it won't appear in "Assigned Work" tab.

Video Reference:

Assigned Work Tab in Salesforce Omni-Supervisor


Salesforce Forecasting


Follow the below steps to enable Forecasting in Salesforce and check it's usage quickly and easily.

1. Go to Forecast Settings in Setup.


2. Enable Forecast.

Note:
By default it creates Opportunity Revenue Forecast using Closed Date field.


3. Open Forecasts Tab.


Video Reference to Setup Salesforce Forecast:

How to quickly setup Forecasting in Salesforce

Salesforce Dashboard Refresh Limits

1. Salesforce supports only 200 per hour per org for Dashboard refreshes.
 
2. A dashboard can be refreshed using Refresh button every minute(60 seconds).


3. Dashboard can have 20 components. Dashboard with less number of Source Reports runner quicker.

Reference Help Article: 

How to avoid update to Case record when the Status is Working in Salesforce?

Validation Rule can be used to avoid update to Case record when the Status is Working.

Validation Rule Formula:
AND(
ISPICKVAL( Status, 'Working' ),
ISPICKVAL( PRIORVALUE( Status ), 'Working' ),
NOT( ISNEW() )
)


Note:
When the Case is updated with Working status, the Validation Rule will fire.
When the Case is created with Working status, the Validation Rule will not fire.
When the Case is updated from Working to a different status, the Validation Rule will not fire. 

Salesforce Deployment Stuck at Cancel

Salesforce Deployment will be updated to Canceled status when the deployment is completely canceled. It might take time based on the components that are getting deployed.
Reference Article:
https://help.salesforce.com/s/articleView?id=sf.deploy_monitoring.htm&type=5

If you are deploying Sharing Related components, then enable the Deferred Sharing feature.
Reference Help Article:
https://help.salesforce.com/s/articleView?id=sf.security_sharing_rule_recalculation.htm&type=5
After the deployment, you can disable Deferred Sharing and use Sharing Recalculation.

How to hide Embedded Service Chat in Salesforce Experience Cloud Site?


There are several scenarios or use-cases where we want to hide the Chat feature temporarily. 
 
If you want to hide the Chat feature temporarily, then follow the below steps:

1. Open the Experience Cloud builder.

2. Disable "Display chat button".


Video Reference:

Temporarily Disable or Hide Chat in Salesforce Experience Cloud Site

How to create Draft Knowledge Article with related records from Published Knowledge Article using Trigger in Salesforce?

KnowledgeArticle is parent entity.
KnowledgeArticleVersion is child entity.

When a new Knowledge Article is created, it creates an entry in KnowledgeArticle and also in KnowledgeArticleVersion.

When a new Knowledge Article is created as Draft(Edit As Draft), it creates an entry in KnowledgeArticleVersion. It will be child to the KnowledgeArticle with status Draft.

Note:
In Salesforce, actions like changing the publication status of a KnowledgeArticeVersion(__kav) record such as Publish and Archive, do not fire Apex triggers.
Reference Article:

Below trigger can be used to create child records(related records), when an article is created using Edit As Draft quick action. This trigger creates new related records.

Sample Trigger:

trigger KnowledgeTrigger on Knowledge__kav ( after insert ) {

    Set < Id > setKAIds = new Set < Id >();

    for ( Knowledge__kav objKnowledge : trigger.new ) {
    
        if ( objKnowledge.PublishStatus == 'Draft' ) {
            
            /* 
                Getting the KnowledgeArticleId
                Each KnowledgeArticleVersion will be tied to one KnowledgeArticle
            */
            setKAIds.add( objKnowledge.KnowledgeArticleId );
        
        }
    
    }
    
    if ( setKAIds.size() > 0 ) {
    
        Map < Id, Knowledge__kav > mapArticleIdKnowledge = new Map < Id, Knowledge__kav > ();
        List < Process__c > listProcesses = new List < Process__c >();
        List < Follow_Up__c > listFollowUps = new List < Follow_Up__c >();
        
        for (  Knowledge__kav objKnowledge : 
            [ SELECT Id, KnowledgeArticleId, 
            ( SELECT Name FROM Processes__r ), 
            ( SELECT Name FROM Follow_Ups__r )
            FROM Knowledge__kav
            WHERE KnowledgeArticleId IN: setKAIds AND PublishStatus = 'Online' ]
        ) {
            
            /*
                This map will hold the master KAV from which the draft is created
            */
            mapArticleIdKnowledge.put( objKnowledge.KnowledgeArticleId, objKnowledge );
        
        }
        
        for ( Knowledge__kav objKnowledge : trigger.new ) {
    
            if ( objKnowledge.PublishStatus == 'Draft' ) {
            
                if ( mapArticleIdKnowledge.containsKey( objKnowledge.KnowledgeArticleId ) ) {
                
                    Knowledge__kav tempKnowledge = mapArticleIdKnowledge.get( objKnowledge.KnowledgeArticleId );
                
                    /*
                        If the Master KAV had Process related records, then new records are created with the Draft KAV
                    */
                    if ( tempKnowledge.Processes__r.size() > 0 ) {
                        
                        for ( Process__c objProcess : tempKnowledge.Processes__r ) {
                        
                            Process__c tempProcess = objProcess.clone( false, false, false, false );
                            tempProcess.Knowledge__c = objKnowledge.Id;
                            listProcesses.add( tempProcess );
                        
                        }
                        
                    }
                
                
                    /*
                        If the Master KAV had Follow Up related records, then new records are created with the Draft KAV
                    */
                    if ( tempKnowledge.Follow_Ups__r.size() > 0 ) {
                        
                        for ( Follow_Up__c objFollowUp : tempKnowledge.Follow_Ups__r ) {
                        
                            Follow_Up__c tempFollowUp = objFollowUp.clone( false, false, false, false );
                            tempFollowUp.Knowledge__c = objKnowledge.Id;
                            listFollowUps.add( tempFollowUp );
                        
                        }
                        
                    }
                
                }
            
            }
        
        }
        
        if ( listProcesses.size() > 0 ) {
            
            insert listProcesses;
            
        }
        
        if ( listFollowUps.size() > 0 ) {
            
            insert listFollowUps;
            
        }
    
    }
    
}

Salesforce API Security Token

When we access Salesforce from an IP address that’s outside your company’s trusted IP ranges using a desktop client or the API, we need a security token to log in. 
 
Salesforce Trusted IP Ranges:
 

Note:
Trusted IP Ranges is different from Profile IP Ranges. 

1. To hide "Reset my Security Token" option in Salesforce, add IP ranges to the profile. If the Login IP Ranges are set, Security Token is not needed.
 
2. We will receive a new security token email when we reset the password for the user. Check the email associated with the user account to get the Security Token.

3. If MFA(Multi-Factor Authentication) for API Logins permission is enabled on the profile, use the code generated by an Authenticator app, such as Salesforce Authenticator for the security token value.
 
4. To get API only users to receive a security token reset email when you reset their password, use the following steps.

a. Temporarily assign the API Only user to a profile that doesn’t have the API only user permission.
b. Request the user to manually reset their security token. As an Admin do not impersonate(Logging using Login button).
c. Reassign the user to the Profile back with the API only user permission.

Reference Articles:

How to Auto Refresh Salesforce Dashboard in Lightning Experience without sending email?

1. Open the Dashboard.

2. Click Subscribe.

3. Select Frequency and Time.
Note:
Disable "Receive new results by email when dashboard is refreshed to avoid receiving emails.


How to check pre-chat information in Salesforce Omni-Flow?


1. Create a variable with the name prechatInfo.


2. Use Loop element in the loop to iterate it.


3. Decision element can be used to check key and value. Also, Assignment element can be used.



Video Reference:
 
How to check or iterate Pre Chat information in Salesforce Omni Flow