Slack Integration with Salesforce

An architect can design Slack Integration with Salesforce in 3 ways:

  1. Salesforce provides a free AppExchange manage package by which a developer can seamlessly automate the bidirectional integration between Slack and Salesforce
  2. There are Slack Apps like Rattle, Troops that provide Salesforce integration capability from the third party. Also, explore Apps in the Slack App directory for other kinds of integration capability
  3. Build your own integration in Salesforce using Slack Webhook
Slack and Salesforce Integration
Slack and Salesforce
  1. Salesforce for Slack: An AppExchange App by Salesforce to seamlessly send Salesforce records to a Slack channel. Trailhead provides a robust hands-on module on this https://trailhead.salesforce.com/content/learn/projects/integrate-salesforce-with-slack/install-salesforce-for-slack-and-grant-permissions
  2. Slack Apps by Third Party: There are many Third party apps to achieve Salesforce integration, few are even free.
    1. Troops is a very interesting App, update Salesforce record directly from Slack. It automates many Slack workflows. Troops is now a Salesforce company. https://www.troops.ai/
    2. Rattle provides robust Salesforce and Slack integration capability, it’s a license-based product. https://www.gorattle.com/
  3. A developer can build its own integration in Salesforce using Slack API and Webhook. below are high-level steps:
    1. Create an Incoming WebHook in the Slack workspace
    2. Whitelist the Webhook URL in Salesforce Remote Site Setting
    3. Build an APEX class with an Invocable method to call the webhook URL and send the Slack Request. Make use of JSON Generator class to serialize the JSON with standard encoding https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_JsonGenerator.htm Also make use of Slack message formatting documentation to format the text for app surfaces https://api.slack.com/reference/surfaces/formatting.
    4. That invocable method now can be called from a Flow or APEX.

Contact – Twirl World (twirltech.in)

Customer Service

Salesforce Social Customer Service

Turn social network posts into cases or leads with Social Customer Service. Service Agents can reply to social network posts from the Service Console. Salesforce Social Customer Service capability is delivered by Marketing Cloud Social Studio which is integrated with Salesforce Platform seamlessly.

Channels supported as of now:

  1. Facebook
  2. Twitter
  3. Instagram
  4. YouTube

There are two solutions to implement Social Customer Service, Basically, both are delivered by MC Social Studio.

  1. Social Customer Service Starter Pack: Comes with Service Cloud License, General limits are:
    1. Two or fewer social accounts can be tracked. So f you add one Twitter account, you can only add another Twitter account or one Facebook account
    2. No moderation rule, all posts become cases
    3. Instagram and YouTube aren’t available
    4. Can’t customize the default Apex code. The default Apex class creates a social post, social persona, case, and contact, and supports common use cases which can be customizable if you have Social Studio accounts
  • Social Studio accounts Marketing Cloud Social Studio implementation. Connector in Service cloud to integrate with MC Social Studio.

The features are:

  • Create Cases or leads from Social network posts and Assignment Rule to assign the cases to agents
  • Agents can directly respond back to customers to the Social Channels from the Service Console
  • Inbound and outbound social posts appear in case histories
  • Track customer sentiments and keywords” and help agents offer to take public conversations private
  • Send service requests directly to the Service Console, where agents can switch the conversations to the best channels for customers at any time.
  • Bring sales, service, and marketing teams together on social platforms to collaborate on the customer experience

Does the customer wants a few specific agents who are assigned to handle social posts from customers:

Admin can control the access via the permission set and profile permissions to access the social accounts.

If there is a governance requirement to review and approve responses from agents to social posts before making them public:

Admin can create an approval process for social services in which to assign service managers or marketers. Enable approvals for social posts in Social Customer Service Setup.

Can the agent share a file to the posts on social platforms for customers:

Send the attachment/file link to the post. Give the Run Apex As User in Social Customer Service Setup permission to Create Public Links.

Does the customer wants to moderate and triage incoming posts and only create cases for posts that have actionable requests:

Not available in the Social Customer Service Starter Pack. Social Studio account and its Social Studio Automate rule to turn off automatic case creation and enable moderation.

Salesforce Social Customer Service
Salesforce Social Customer Service

Read more at https://help.salesforce.com/s/articleView?id=sf.social_customer_service_overview.htm&type=5

https://twirltech.in/

Render Google Map in Salesforce LWC

To render Google Map in Salesforce LWC we have a couple of options, let’s discuss those first:

  • MAP Base Component in LWC

Out of the Box in Salesforce, no need for additional Google MAP API; Only Plots the traverse points in the map, no route information

https://developer.salesforce.com/docs/component-library/bundle/lightning-map/documentation

Render Google Map in Salesforce LWC
  • Google MAP API implementation ONLY in LWC

Technically, this is not possible at this moment due to Security with Lightning Locker Services which prevents to run a script from a different domain/CDN

  • Google MAP API implementation with LWC + VF

The only possible design currently is placing a VF inside an LWC to render the Google Map and show the route. All logic is inside the LWC- VF is only for rendering

Render Google Map in Salesforce LWC
  • Buy Field Service Lighting or SALESFORCE MAPS licenses

We will only discuss the Google MAP API implementation with LWC + VF solution in this block. This is the only possible solution that needs customization in LWC, VF and APEX.

Prerequisite: Google MAP API License key for commercial use

The solution and Implementation steps are:

  1. A Quick Action to add a Lightning LWC Button to a page layout to access google form.
  2. Clicking on the button will open an LWC Component, LWC component will get the current record id and will call the apex controller to get the data.
  3. Get all required field information from the Apex controller class.
  4. Pass the Information info to the VF page to render the Google Map.
  5. Google Map is dynamically rendered based on the JSON input received from the LWC component.
  • It has one iframe to host the VF page that will render the Google Map by using the google map javascript library.
    • This solution has one unique challenge – to communicate data from the LWC component to the VF page and from the VF page to send the data to the Google Javascript library. All event sequences need to be followed properly.
    • LWC component will read data from the salesforce object and send the location data to google Map.
  • It plots all the locations to Map with the route.
  • The right-hand side panel shows the distance between each point. All Data is dynamically populated from google maps.
Render Google Map in Salesforce LWC

VF code to render Google MAP

<apex:page showHeader="false" >
    <apex:includeLightning />
    <div id="rcontainer">
    </div>   
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
        <title>Google Maps API v3 Directions Example</title>
        <script type="text/javascript" src="//maps.google.com/maps/api/js?key=GOOGLE API KEY"></script>
    </head>
    
    <body style="font-family: Arial; font-size: 12px;">
        
        
         <script >
                
            /*** EventListener to GET response from LWC  ***/
                   /*** EventListener to GET response from LWC  ***/
window.addEventListener("message", function(event) {
    var directionsService = new google.maps.DirectionsService();
    var directionsDisplay = new google.maps.DirectionsRenderer();
    
    var map = new google.maps.Map(document.getElementById('map'), {
            zoom:7,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
        	mapTypeControl: true,
        disableDefaultUI: false,
        

    });
    directionsDisplay.setMap(map);

    directionsDisplay.setPanel(document.getElementById('panel'));
    console.log('vf page data'+event.data);
    var request = {
        origin: '',
        destination: '',
        waypoints: [],   
        travelMode: google.maps.DirectionsTravelMode.DRIVING
    };
        console.log('request1'+request);
    let counter=0;
    for (let i = 0; i < event.data.length; i++) {
        console.log('Check_In_Location__Latitude__s'+event.data[i].Check_In_Location__Latitude__s);
         console.log('Check_In_Location__Longitude__s'+event.data[i].Check_In_Location__Longitude__s);
        if(i==0){
            var StartLocationA = new google.maps.LatLng(event.data[i].Check_In_Location__Latitude__s, event.data[0].Check_In_Location__Longitude__s);
            request.origin=StartLocationA;
            console.log('request2'+request);
        }
        else if(i==event.data.length-1){
            var EndLocationB = new google.maps.LatLng(event.data[i].Check_In_Location__Latitude__s, event.data[0].Check_In_Location__Longitude__s);
            request.destination=EndLocationB;
            console.log('request3'+request);
        }
        else{
            
            var StopOver1 = new google.maps.LatLng(event.data[i].Check_In_Location__Latitude__s, event.data[0].Check_In_Location__Longitude__s);
            var waypointjson={
                          location: StopOver1,
                          stopover: true,
                        };
            request.waypoints[counter]=waypointjson;
            counter++;
            console.log('request4'+request);
        }
    }
    
    
    directionsService.route(request, function(response, status) {
        if (status == google.maps.DirectionsStatus.OK) {
            directionsDisplay.setDirections(response);
           	hideDetail();
            
        }
    });
});
        //This is a POC code, Loading div needs to implemented for actual implementation
        function hideDetail() {
  			
            setTimeout(
    			function() {
      				for (let i = 0; i < document.getElementsByClassName('adp-directions').length; i++) {
  						document.getElementsByClassName('adp-directions')[i].style.display='None';
					}
    			}, 100);
            setTimeout(
    			function() {
      				for (let i = 0; i < document.getElementsByClassName('adp-directions').length; i++) {
  						document.getElementsByClassName('adp-directions')[i].style.display='None';
					}
    			}, 500);
            setTimeout(
    			function() {
      				for (let i = 0; i < document.getElementsByClassName('adp-directions').length; i++) {
  						document.getElementsByClassName('adp-directions')[i].style.display='None';
					}
    			}, 1000);
			}
        
             const contentString =     				;

  			const infowindow = new google.maps.InfoWindow({
    			content: contentString,
  			});

        </script>
    </body>
</apex:page>

https://twirltech.in/

Amazon Connect for Salesforce

Amazon Connect for Salesforce is a Manage Package that helps to configure Amazon Connect Computer Telephony integration with Salesforce, it’s a very simple process to receive incoming calls and make outgoing calls right from Salesforce. Now, don’t get confused between Amazon for Salesforce and Service Cloud Voice.

AWS Contact Center is seamlessly integrated with Salesforce by Amazon Connect for Salesforce whereas Service Cloud Voice provides a more sophisticated AI-powered feature on top of the Amazon Connect for Salesforce, but not limited only to AWS Contact Center. Service Cloud Voice provides support for other Partner Telephony and lets you create a Service Cloud Voice contact center that uses a telephony provider of your choice. I will talk about Service Cloud Voice in my next article.

Amazon Connect is a highly scalable, cloud-based contact center service. The Amazon Connect CTI Adapter is the Manage Package that is designed to provide complete cloud-based integration and workflow capabilities between Amazon Connect, Salesforce Service Cloud, and Sales Cloud.

Amazon Connect for Salesforce
Amazon Connect for Salesforce

The Amazon Connect CTI integration with Salesforce consists of two components:

  • A Manage package can be installed from the below link

https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000EJH4yUAH

  • An Application deployment at your AWS instance

https://serverlessrepo.aws.amazon.com/applications/arn:aws:serverlessrepo:us-west-2:821825267871:applications~AmazonConnectSalesforceLambda

The full set-up guidance can be found is in the below link

https://amazon-connect.github.io/amazon-connect-salesforce-cti/docs/lightning/notices/

Find more blogs at https://twirltech.in/

Encryption in Salesforce

When we talk about Encryption in Salesforce, There are typically three kinds of encryption you may need to secure your data:

  • Encription at rest
  • Encription during transit
  • Encription during usuage

Here we will be going to talk about Encryption at rest which is provided by Salesforce Shield which provides 3 products:

  • Event Monitoring
  • Field Audit Trail
  • Encryption

Encryption

Protect data at rest – Encrypt standard & custom fields, files & attachments

Natively to Salesforce features like Search, Chatter, Relationship work with encrypted data

Bring your Own Key: Customer can manage keys, Customer-driven encryption key lifecycle management

Encryption in Salesforce
Salesforce Shield

Find more details at https://developer.salesforce.com/docs/atlas.en-us.securityImplGuide.meta/securityImplGuide/salesforce_shield.htm

There are two types of Shield Encryption: Deterministic & Probabilistic. Deterministic encryption is for the field which you need in the where clause in a query but the Probabilistic type ensures extra security than the Deterministic type.

Don’t get confused between Classic encryption and Shield platform encryption, Classic encryption is also provided on top of the platform with no cost but it doesn’t support the Standard field, File, also it provides 128 bit AES and user access to the encryption field is managed by permission set

https://twirltech.in/architect-blogs/

Salesforce Unlock Package

There are three kinds of packages one can build in the Salesforce platform, Out of which Salesforce Unlock Package is very powerful for the use-case of project deployment, release management, and CICD.

  1. Manage Package: Metadata is IP Protected, distributed via AppExchange
  2. Unmanage Package : Metadata is not IP Protected, you can protect via password but not a good way of working
  3. Unlock Package: Metadata elements are not locked, use it for modular development

Salesforce Unlock package provides a great way for modular development and release, Best suited for Multi org rollout of core functionalities. The diagram below illustrates the unlock packaging and release via Salesforce CLI. Core reviews can also be automated using Salesforce CLI Scanner plug-in using PMD v6.38.0, ESlint v6.8.0, and RetireJS v2.2.5. My blog on Salesforce Code Review Process has more details on that https://twirltech.in/2021/10/salesforce-code-review-process/

It’s Source driven development and deployment mechanism comes with Platform, no-cost, fully integrated with developer IDE VS Code

Salesforce Unlock Package
Salesforce Unlock Package

Refer to the Salesforce developer guide to get your hands dirty https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_unlocked_pkg_intro.htm

Salesforce Experience Cloud and Record Sharing

Salesforce Experience Cloud has three types of user licenses that are intended as long-term replacements for the legacy portal licenses and these licenses have different capabilities for Salesforce Experience Cloud and Record Sharing to ot’s users.

  • Customer Community — for high-volume user. upper cap 10M
  • Customer Community Plus — role-based Customer Community license, upper cap 2M
  • Partner Community — For Sales Partner, upper cap 2M

Below decision tree will help to decide the right Community license for your organization

Choose the Right Community License

Record Sharing to Experience Cloud User

There Is only one feature in Salesforce to share a record with a Customer Community user: Sharing Set. The other sharing options are only available to the Customer Community Plus or Partner Community license via Groups, Roles

Sharing Set: Grant a user access to records based on affiliation with the user’s contact or account. A relation with Account or Contact is a must to share the object record via Sharing ser. The rule is something like for a requirement share the cases which are raised by a community user User.Contact=Case.Contact

Sharing Set

https://help.salesforce.com/s/articleView?id=sf.networks_setting_light_users.htm&type=5

Share Group: Members of this share group can access any records owned by high-volume portal users in the associated sharing set. Note that members’ access to the records is not restricted to the objects defined in the sharing set.

Use share groups to share records owned by an external user (Customer Community or High-Volume Customer Portal ) with internal users, partner users, or other Customer Community users in the same account.

Share Group

Sharing Rule: Just like other Salesforce internal users, Owner and Criteria-based sharing rules can be used to share records within the Partner Community and Customer Community Plus.

Apex sharing is not available for Customer Community users, only available to the Customer community plus or Partner Community license
Role Hierarchy: Partner Community and Customer Community Plus can have Role Hierarchy, max 3 roles (Executive, Manager and User) and then Executive reports to Internal Channel Manager.

Delegate External User Administration

If partner organizations have many users, you can delegate user administration to external users within their own Account, access is given in their Profiles

Super User Access to a Partner User or CC+

grant access to all records for the account to certain users. Super users can get insights into the records of other partner users who are at their role level or below them in the role hierarchy. Superusers can access records according to their level of permission. For example, if a manager with full access to cases is granted Super User Access, then they can view and edit cases of other managers and their direct reports. A different manager who has read-only access to cases can only view the cases of other managers and their direct reports, even as a Super User. Available for Partner Community, Customer Community Plus

Delegated Account Management

Give external users the power to manage account members and account brand information. Available for Partner Community, Customer Community Plus

Community License and Object Access

https://twirltech.in/architect-blogs/

Salesforce File

Salesforce File and Data Model

In this article, we will be going to give a few important information about Salesforce File. The lightning experience uses Salesforce Files for any Content, Attachments, Files, Content, and Documents. The internal object name is ContentDocument. Salesforce File and Data Model

ContentDocument object represents a document that has been uploaded to a library in Salesforce CRM Content or Salesforce Files

Salesforce File and Data Model
Content Document Object Model

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentdocument.htm

Now the ContentDocumentLink object represents the link between a Salesforce CRM Content document, Salesforce file, or ContentNote and where it’s shared. A file can be shared with other users, groups, records, and Salesforce CRM Content libraries

Use this object to query the locations where a file is shared or query which files are linked to a particular location. For example, the following query returns a particular document shared with a Chatter group

  • Point to note that both ContentDocument and ContentDocumentLink objects are not customizable, you cannot add custom fields.
  • Use the ContentDocumentLink  object to query the locations where a file is shared or query which files are linked to a particular location. For example, the following query returns a particular document shared with a Chatter group

SELECT ContentDocument.title FROM ContentDocumentLink WHERE ContentDocumentId = ‘069D00000000so2’ AND LinkedEntityId = ‘0D5000000089123’

  • The ContentDocumentLink object supports triggers 

These are the few important settings when you enable File in a Salesforce organization

If you are using File Connect then the external files (like from Google Drive, SharePoint, Box etc) can be connected to Salesforce.

For more articles, please visit https://twirltech.in/blog/

Salesforce Code Review Process

There are many AppExchange tools for Salesforce Static code analysis, few of the market leaders are SonarQube, CheckMarx, CodeScan. PMD (Programming Mistake Detector) is also a popular option. These tools help the Release Manager in Salesforce Code Review Process.

I will not go through each tool’s capability rather highlight my opinion and comparison between two of my personal favorite CodeScan and PMD; Paid vs Open Source. And Lastly want to cover Salesforce CLI Scanner which can be a viable alternative.

Salesforce Code Review Process
PMD
  1. PMD has a set of built-in rules available for both Apex and Visualforce pages. Static ruleset with define priority n PMD for Apex.

2. Finds common programming flaws like unused variables, empty catch blocks, unnecessary object creation, and so forth

3. Supports Salesforce Apex & Visualforce

4. Plugin for VS Code, ANT build, Eclipse 

5. It is Open-source which doesn’t have any licensing cost

Major drawback – The scan doesn’t review Lightning and LWC Components.

https://pmd.github.io/latest/pmd_rules_apex.html

Salesforce Code Review Process
CodeScan

CodeScan Features

  1. Codescan is an end to end code analysis solution to ensure quality and security of Salesforce orgs 2.
  2. 350+ security and quality rules for Apex, Visualforce, Lightning and Metadata
  3. IDE plugins helps developers to get the review on real time to address any issues with the code quality
  4. 4.Integrates directly with Salesforce and all popular CI/CD pipelines, Integration with Jira
  5. Covers Lightning Component and Javascript related issues and standards.
  6. Easy to configure/modify a ruleset as needed
  7. It is not open source. License cost is involved. Self-host or cloud plan

CODESCAN INTEGRATIONS
CodeScan SFDX Plugin
IDE Plugins
AutoRABIT
Copado
Flosum
Azure DevOps
GitLab
Bitbucket Pipelines
GitHub Actions
Jenkins
Webhooks

https://www.codescan.io/

Code Quality check with the Salesforce CLI Scanner

The Salesforce CLI Scanner plug-in is a unified tool for static analysis of source code. Developer can install the plug-in on a local developer machine or integrate it into a CI/CD process to scan the code.

It can be seamlessly integrated with Salesforce dx release management to automate the code review process.

Salesforce CLI Scanner plug-in uses PMD v6.38.0, ESlint v6.8.0, and RetireJS v2.2.5 at this moment. Salesforce is actively implementing new features to further improve Salesforce CLI Scanner.

PMD is a source code analyzer that allows for static analysis of code written in a number of supported languages, including Java, Apex, and Visualforce. It’s built-in rules detect common flaws in code, such as empty catch blocks or unused variables.

ESLint is a popular linting tool for JavaScript. It provides numerous static analysis rules that help developers write quality code.

RetireJS is an engine that analyzes a project’s third-party JavaScript dependencies and identifies those that have known security vulnerabilities

Plugin Design
Salesforce CLI Scanner

https://forcedotcom.github.io/sfdx-scanner/en/getting-started/prerequisites/

https://twirltech.in/architect-blogs/

Salesforce Einstein Analytics Deployment

Salesforce Einstein Analytics Deployment: Salesforce Einstein Analytics components can be deployed in orgs via three ways:

If the Einstein Analytics components will be deployed to a related org then Change set is the best option.
Else Package-based metadata deployment using VS Code is the freeware to carry out the deployment.

There are deployment tools like AutoRabit, Copado Gearset etc who supports Einstein Analytics component deployment seamlessly but the assumption here is customers don’t have a license of any of those tools.

Before starting, please make sure who is carrying out the deployment has the below permission

  • Manage Analytics
  • API enabled
  • Modify Metadata
  • Modify All Data

Below is the package.xml

<types>
  <members>Analytics</members>
  <name>Settings</name>
<members></members>
  <name>WaveApplication</name>
<members></members>
  <name>WaveDataflow</name>
<members></members> 
  <name>WaveDashboard</name>
<members></members>
  <name>WaveDataset</name>
<members></members>
  <name>WaveLens</name>
<members></members>
<name>WaveComponent</name>
<members></members>
  <name>WaveRecipe</name>
<members></members>
  <name>WaveXmd</name>
</types> 
  • Security Predicates update is a post deployment manual task

Connect to the source org from VS code and retrieve the components using the above xml. Then connect to the destination org and deploy.

Please be cautious about any component override.

Change set based deployment link

https://help.salesforce.com/s/articleView?id=sf.bi_packaging_migrate.htm&language=en_US&r=https%3A%2F%2Fwww.google.com%2F&type=5

https://twirltech.in/architect-blogs/