Category Archives: Salesforce

Salesforce

Blending Best of Both Worlds: React JS into Salesforce Lightning Web Components (LWC)

Integrating React within a Salesforce Lightning Web Component (LWC) is a unique approach since LWC and React are both frameworks designed to control the DOM in their ways. However, it is possible to use them together, though it requires careful handling to ensure both libraries can coexist without issues.

React JS within LWC

Step 1: Setting Up Your Salesforce DX Environment

  1. Install Salesforce CLI: Make sure you have the Salesforce CLI installed on your computer. This is essential for creating and managing your Salesforce development projects.
  2. Create a New Salesforce DX Project: Open your terminal and run the command sfdx force:project:create -n myLwcReactProject to create a new project.
  3. Navigate into Your Project: Use cd myLwcReactProject to move into your project directory.
  4. Authorize a Dev Hub: If you haven’t already, authorize a Salesforce Dev Hub by running sfdx auth:web:login -d -a DevHub.
  5. Create a Scratch Org: Create a new scratch org with sfdx force:org:create -s -f config/project-scratch-def.json -a LwcReactOrg.
  6. Open the Scratch Org: To access your newly created org, use sfdx force:org:open.

 Install the lwc-react package. You can do this by running the following command in your terminal:

npm install lwc-react

Step 2: Import React to Your Salesforce Project

  1. Navigate to the LWC Directory: Within your project, navigate to force-app/main/default/lwc.
  2. Create a React App: You cannot directly create a React app here. Instead, you’ll integrate React manually. Download React and ReactDOM from a CDN or NPM and include them in your Salesforce static resources.
  3. Static Resource for React: Create a static resource for both React and ReactDOM. Use Salesforce Setup to upload these files as static resources.

Step 3: Creating Your LWC Component

  1. Generate LWC Component: Use sfdx force:lightning:component:create --type lwc -n myReactComponent -d force-app/main/default/lwc.
  2. Edit Your Component: In your myReactComponent directory, you’ll find three files: myReactComponent.js, myReactComponent.html, and myReactComponent.css. You’ll primarily work with the JS and HTML files.

Step 4: Integrating React into Your LWC

  1. Load React and ReactDOM: In myReactComponent.js, use loadScript from lightning/platformResourceLoader to load React and ReactDOM from the static resources you uploaded.
  2. Use React in Your Component: After loading React and ReactDOM, you can use them within the renderedCallback lifecycle method to render React components inside your LWC.
  3. Update Your HTML Template: Add a container in your myReactComponent.html where the React component will be mounted.

There is React Library published by Salesforce which can be used seamlessly within LWC

https://react.lightningdesignsystem.com/

import { LightningElement, track } from 'lwc';
import { loadScript } from 'lightning/platformResourceLoader';
import REACT from '@salesforce/resourceUrl/react';
import REACTDOM from '@salesforce/resourceUrl/reactdom';

export default class MyReactComponent extends LightningElement {
    reactInitialized = false;

    renderedCallback() {
        if (this.reactInitialized) {
            return;
        }
        this.reactInitialized = true;

        Promise.all([
            loadScript(this, REACT + '/react.production.min.js'),
            loadScript(this, REACTDOM + '/react-dom.production.min.js')
        ])
        .then(() => this.initializeReactComponent())
        .catch(error => console.error(error));
    }

    initializeReactComponent() {
        ReactDOM.render(
            React.createElement('div', null, 'Hello from React!'),
            this.template.querySelector('.reactContainer')
        );
    }
}

Add a container in your myReactComponent.html where the React component will be mounted

<template>
    <div class="reactContainer"></div>
</template>

Considerations

  • Performance: Embedding React inside an LWC can impact performance because of the overhead of loading React and managing two frameworks.
  • Framework Conflicts: Be mindful of potential conflicts between React’s and LWC’s handling of the DOM.
  • Maintenance: This approach requires careful maintenance, as updates to either framework can necessitate changes to your integration.

For more details

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

Unlocking the Power of Salesforce Data Cloud: A Comprehensive Guide for Businesses

Are you ready to unleash the full potential of your business by harnessing the power of data? Look no further than Salesforce Data Cloud – a game-changing tool that empowers businesses with invaluable insights and strategic advantages. This comprehensive guide will delve into the depths of Salesforce Data Cloud, exploring its myriad benefits and unlocking its true power for your organization. Get ready to supercharge your decision-making processes, unlock hidden opportunities, and take your business to new heights with this ultimate resource!

Salesforce Data Cloud

Introduction to Salesforce Data Cloud

Salesforce Data Cloud is a powerful platform that enables businesses to unlock their customer data’s full potential. It is an integrated solution that combines data management, analytics, and AI capabilities to provide a holistic view of customer information. With its vast consumer and business data collection, Salesforce Data Cloud helps businesses gain valuable insights into their target audience, enhance their marketing strategies, and drive growth.

https://www.salesforce.com/in/products/genie/overview/

What is the Salesforce Data Cloud?

Salesforce Data Cloud is a cloud-based platform that offers access to one of the world’s largest collections of third-party consumer and business data. This includes over 30 billion records from over 300 million active users globally. The platform also provides real-time updates on demographic, firmographic, behavioral, and purchase intent data from various sources, such as social media platforms, government agencies, credit agencies, and more.

The primary goal of Salesforce Data Cloud is to help companies leverage this vast amount of data to understand their customers and create personalized experiences for them at every touchpoint. By integrating with the Salesforce Customer 360 platform, businesses can seamlessly connect customer data across multiple channels and devices.

Benefits of Using Salesforce Data Cloud

Salesforce Data Cloud is a powerful tool that has revolutionized how businesses handle and analyze customer data. With its advanced features and capabilities, Salesforce Data Cloud offers a wide range of benefits to businesses looking to maximize the potential of their data. This section will explore some of the key benefits of utilizing Salesforce Data Cloud for your business.

There are numerous benefits that businesses can reap by utilizing Salesforce Data Cloud:

1) Improved Customer Insights: With access to a diverse range of high-quality data points on consumers and businesses worldwide, companies can gain deeper insights into their target audience’s preferences, behavior patterns, buying habits, etc. This information allows them to personalize

2) Centralized Data Management:

One of the biggest advantages of using Salesforce Data Cloud is its ability to centralize customer data in one place. You no longer have to deal with fragmented data across different systems and platforms. With Salesforce Data Cloud, you can easily access and manage customer data from a single interface, allowing for better organization, collaboration, and analysis.

3) Real-Time Access to Relevant Customer Information:

Salesforce Data Cloud provides real-time access to relevant customer information, enabling businesses to make informed decisions based on accurate and up-to-date data. This is especially useful for sales teams who need quick insights into customers’ preferences, purchase history, and behavior patterns.

4) Enhanced Personalization:

With Salesforce Data Cloud’s advanced analytics capabilities, businesses can gain valuable insights into their customers’ behaviors and preferences. This allows them to personalize their marketing efforts and tailor their products or services according to individual needs, improving customer satisfaction and loyalty.

Visit https://twirltech.in/architect-blogs/ for more articles.

Options to Integrate Chat GPT with Salesforce

Open AI
Salesforce

In this section, we will go over the various options of chat gpt and salesforce integration. There are three ways to achieve Chat GPT with Salesforce:

  1. Build a custom integration using the Salesforce APEX to call GPT Model API
  2. Pre-built integration packages or solutions are available on the Salesforce AppExchange
  3. Create and Host a GPT model on any public cloud or local machine.

I don’t believe any ISV partner (https://appexchange.salesforce.com/) has already developed a package to integrate with the GPT Model. Also, creating and hosting a GPT model can be a complex task that requires a good understanding of machine learning and artificial intelligence.

GPT-3 is a pre-trained model that OpenAI provides; it is not publicly available to download and host on one’s local server or in the public cloud. So, options #2 and #3 are invalid at this moment.

Integrate GPT-3 Model API with Salesforce

We must use the API made available by the service that hosts the GPT model in order to call the predicted text from a Chat GPT model. Send an HTTP request from APEX to a specific endpoint. The body of the request is where you put any needed authentication information or parameters. High-level steps to Integrate Chat GPT with Salesforce

  1. Sign up for an API key from OpenAI
    • Go to the OpenAI website (https://openai.com/) and click on the “Sign In” button in the top right corner of the page.
    • After signing in, click on the “API” button at the top of the page.
    • Click on the “Create an API Key” button on the API page.
    • Provide a name for your API Key and select the permissions you want to grant to the key.
    • Click on the “Create” button to create the key.
  2. Once you have an API key, you can use it to request the GPT-3 API.
  3. The endpoint for generating text from a GPT-3 model is: https://api.openai.com/v1/engines/davinci-codex/completions
  4. You can make a POST request to this endpoint with a JSON payload that includes your API key, the text you want to generate completions for, and any other parameters you want to customize the generated text.
import json
import requests

api_key = "YOUR_API_KEY"
model = "davinci-codex"
prompt = "Write something interesting about Salesforce integration"

headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {api_key}"
}

data = {
    "prompt": prompt,
    "engine": model,
    "max_tokens": 50,
    "stop": ["Salesforce integration"]
}

response = requests.post(
    "https://api.openai.com/v1/engines/davinci-codex/completions",
    headers=headers,
    json=data
)

print(response.json())

Make a GPT-3 API HTTP request in Apex

Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api.openai.com/v1/engines/davinci-codex/completions');
request.setMethod('POST');
request.setHeader('Content-Type', 'application/json');
request.setHeader('Authorization', 'Bearer ' + apiKey);
request.setBody(jsonPayload);
HttpResponse response = http.send(request);

if (response.getStatusCode() == 200) {
    // Success, parse the JSON response
    Map<String, Object> jsonResponse = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
    // process the jsonResponse
}
else {
    // Handle the error
}

This merely illustrates how to use the GPT-3 API that OpenAI provides; other providers might require various endpoints, authentication methods, and parameters.

Browse Open API documentation about the endpoints

https://beta.openai.com/docs/models/gpt-3

It’s worth noting that OpenAI only provides the GPT models and not a chatbot service; however, the GPT models can be used as the core of a chatbot. But you must build the chatbot architecture, prompt and context management yourself.

Browse more at https://twirltech.in/architect-blogs/

Deliver Great Patient Care with Salesforce Health Cloud

Salesforce Health Cloud Solution is a Customer Relation Management system that allows users and healthcare staff to access all patient information including medical history and upcoming health check-up appointments in real-time to Deliver Great Patient Care with Salesforce Health Cloud.

Four Major wings connect the healthcare system of an organization

PROVIDERS

•360-degree view of patient  data

•Complete patient experience & Real-time patient coordination and engagement

PAYERS

•Member care management & member journey

•Personalized member services

MEDTECH

•Manage commercial processes, build provider relationships, and engage with patients in a more efficient, compliant, and personal way.

PHARMA

•Deliver personalized patient and provider engagement and support programs while accelerating R&D innovation on a connected platform.

Deliver Great Patient Care with Salesforce Health Cloud
Salesforce Health Cloud

There are two Salesforce Health Cloud Licenses

Health Cloud Enterprise – Out-of-the-box CRM for healthcare and life sciences

Health Cloud Unlimited – Unlimited CRM power and support for healthcare and life sciences.

Use the below document to select right Health Cloud Edition for your business

Health Cloud provides:

  1. A Complete View of the Patient: Comprehensive patient care timeline with
    integrated EMR and device data
  2. Smarter Patient Management: Engage with patients and the entire care team in
    real-time
  3. Proactive Patient Engagement: Allow patients to manage personal healthcare
    goals and access complete care team
Deliver Great Patient Care with Salesforce Health Cloud

Salesforce Console – Allows healthcare professionals to Manage patients with ease
• Segment patients into useful lists based on various criteria in the population
• Track tasks and issues
• Create and execute care plans in the context of the patient’s full picture
o View more than just the patient – Complete care timeline and patient card view
o Facilitate collaboration
• Collaborate with patient teams within the organization
• Coordinate with family caregivers and unaffiliated health
professionals through communities

Deliver Great Patient Care with Salesforce Health Cloud
Health Cloud Console

Salesforce Patient Communities- Allows patients to:

  • Stay on top of health care goals
  • Access to the care plan
  • Reminders and tasks
  • Completion of surveys and forms
  • Easy collaboration with the entire care network
  • Find answers to questions quickly with Knowledge & search
  • Mobile access anytime, anywhere

Salesforce Health Cloud will also bundle Salesforce Shield to achieve HIPAA-compliant use of the product.

Salesforce complies with HIPAA in its capacity as a business associate. Salesforce Health Cloud also includes specific functionality to help customers achieve HIPAA-compliant use of the platform in their role as a covered entity. This includes a robust set of security, privacy, monitoring, logging, and encryption tools through Salesforce Shield to make it safe to store and operate on PHI in Salesforce Health Cloud.

Please find here the health cloud developer guide https://developer.salesforce.com/docs/atlas.en-us.238.0.health_cloud_object_reference.meta/health_cloud_object_reference/object_ref_overview.htm

For more blogs explore Architect Blogs – Twirl World (twirltech.in)

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)

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/