Exploring Winter ’24 Release Enabling ICU Locale Formats in Salesforce

Introduction:

With every new Salesforce release, users and developers eagerly anticipate enhancements and new features that can elevate their experience and streamline processes. In the Winter ’24 release, Salesforce has introduced several exciting updates, and one noteworthy addition is the ability to enable ICU Locale Formats. This enhancement brings a new level of flexibility and customization to the way dates, times, and numbers are formatted in your Salesforce org.

Understanding ICU Locale Formats:

ICU, or International Components for Unicode, is a mature, widely used library for providing globalization capabilities in software applications. In the context of Salesforce, enabling ICU Locale Formats allows users to tailor the display of dates, times, and numbers according to their regional or organizational preferences.

Key Benefits:

  • Localized User Experience: By enabling ICU Locale Formats, Salesforce users around the world can experience a more personalized interface. Dates and numbers will be formatted in a way that aligns with their regional standards, providing a seamless and familiar user experience.
  • Consistency Across Platforms: Salesforce is often used in conjunction with various other platforms and applications. With ICU Locale Formats, you can ensure consistency in the formatting of data across different systems, reducing confusion and improving overall data integrity.
  • Customization Options: Administrators now have greater control over how dates, times, and numbers are presented in the Salesforce user interface. This level of customization allows organizations to adhere to specific formatting requirements or industry standards.

Implementation Steps:

Enabling ICU Locale Formats in your Salesforce org is a straightforward process. Follow these steps to take advantage of this feature:

  • Navigate to Setup: Log in to your Salesforce org and navigate to the Setup menu.
  • Access Language Settings: Under the Setup menu, go to Administration Settings and select Language Settings.
  • Enable ICU Locale Formats: In the Language Settings page, look for the option to enable ICU Locale Formats. Check the box to activate this feature.
  • Choose Locale: Select the specific locale that aligns with your users’ preferences or your organization’s standards.
  • Save Changes: Once you’ve made your selections, save the changes. Salesforce will now apply the ICU Locale Formats to the display of dates, times, and numbers throughout the org.

How:

Before enabling this update in production, check with your package providers to make sure that all your installed packages are compatible with the ICU formats. Then evaluate the new locales’ impact to your Salesforce org. Use this SOQL query to find the locales in use in your org and a user count for each locale.

SELECT toLabel(LocaleSidKey) LocaleName, LocaleSidKey, Count(id) UserCount FROM User where IsActive=true GROUP BY LocaleSidKey

To enable this update, from Setup, in the Quick Find box, enter Release Updates, then select Release Updates. For Enable ICU Locale Formats, follow the testing and activation steps.

The English (Canada) locale (en_CA) requires separate activation. In the Quick Find box, enter User Interface, then select User Interface. Select Enable ICU formats for en_CA locale and click Save.

Conclusion:

The Winter ’24 release in Salesforce brings with it a host of enhancements designed to improve user experience and streamline processes. Enabling ICU Locale Formats is a significant step forward, allowing organizations to provide a more personalized and consistent experience for users across different regions. By taking advantage of this feature, administrators can ensure that their Salesforce org reflects the unique preferences and standards of their user base, contributing to a more efficient and user-friendly platform. Stay tuned for more insights and updates as Salesforce continues to evolve and innovate with each new release. Besides, you can also reach out to NSIQ INFOTECH – best salesforce application development company, to seamlessly enable this update.

Example:

ICA Local Formats English Canada (YYYY/MM/DD)

ICA Local Formats English Canada

ICA Local Formats Franch Canada (YYYY/MM/DD)

ICA Local Formats Franch Canada

ICA Local Formats English US (MM/DD/YYYY)

ICA Local Formats English US

FAQs:

1. What is ICU Locale Formats in Salesforce?

Customers can now customize the way dates, hours, and numerals are displayed in Salesforce to match their corporate or regional preferences thanks to the ICU Locale Formats feature, which was added in the Winter ’24 release. It provides a more consistent and customized user experience by utilizing the International Components for Unicode (ICU) library.

2. Why should I enable ICU Locale Formats in my Salesforce org?

Enhanced customization options, a uniform data formatting experience across platforms, and a localized user experience are some advantages of turning on ICU Locale Formats. By conforming date, time, and numeric formats to local conventions, organizations can improve user experience while preserving data integrity.

3. How do I enable ICU Locale Formats in Salesforce?

To enable ICU Locale Formats, navigate to Setup, go to Administration Settings, and select Language Settings. Check the box to enable ICU Locale Formats and choose the specific locale that aligns with your preferences. Save the changes, and Salesforce will apply the selected formatting throughout the org.

4. Can I customize ICU Locale Formats for different user profiles?

Yes, administrators can customize ICU Locale Formats for different user profiles. This allows organizations to tailor the display of dates, times, and numbers based on the specific needs or preferences of different user groups within the Salesforce org.

5. What happens if I don’t enable ICU Locale Formats?

If you choose not to enable ICU Locale Formats, Salesforce will continue to use the default date, time, and number formatting settings. Enabling this feature is optional, but it provides an opportunity for a more personalized and consistent user experience.

6. Can I revert back to the default formatting after enabling ICU Locale Formats?

Yes, you can revert to the default formatting by going back to the Language Settings in Setup and unchecking the box to disable ICU Locale Formats. However, it’s important to note that this action will affect the formatting across the entire org.

7. How does ICU Locale Formats impact data migration or integration with other systems?

ICU Locale Formats can contribute to a more consistent data presentation across different platforms and systems. When integrating Salesforce with other applications, ensure that the selected locale aligns with the formatting requirements of those systems to maintain data consistency.

8. Are there any considerations for existing data when enabling ICU Locale Formats?

Enabling ICU Locale Formats primarily affects the display of data in the user interface. It does not alter the underlying data itself. Existing data remains unchanged, and the formatting adjustments are applied dynamically when viewing or interacting with records in Salesforce.

9. Can users override the ICU Locale Formats for their personal preferences?

ICU Locale Formats are generally applied at the org level, but users have the flexibility to customize their individual date, time, and number display preferences within their personal settings. These personal preferences can complement the org-wide formatting choices.

10. Are there any performance implications of enabling ICU Locale Formats?

Enabling ICU Locale Formats is designed to provide a better user experience without significant performance impacts. However, it’s recommended to monitor the performance in your specific org and assess whether any adjustments are needed based on the scale and complexity of your Salesforce implementation.

Demystifying Salesforce APIs: A Deep Dive into the Metadata API

Introduction:

In today’s interconnected digital landscape, APIs (Application Programming Interfaces) serve as the backbone of seamless data exchange and integration between different software applications. When it comes to Salesforce, APIs play a pivotal role in extending its capabilities, automating processes, and integrating it with external systems. In this blog post, we’ll explore the Salesforce API ecosystem, with a special focus on the Metadata API – a powerful tool for managing and customising Salesforce configurations.

Overview of Salesforce APIs:

Salesforce provides a comprehensive suite of APIs to enable developers to integrate, extend, and customise Salesforce functionalities according to their specific needs. These APIs cover a wide range of use cases and development scenarios, catering to both lightweight integrations and enterprise-level applications. Let’s explore some of the key APIs offered by Salesforce:

REST API:

Purpose: The REST API is well-suited for building lightweight integrations and developing mobile apps that need to interact with Salesforce data.

Features: It follows the RESTful principles and supports standard HTTP methods such as GET, POST, PUT, PATCH, and DELETE for performing CRUD (Create, Read, Update, Delete) operations on Salesforce data.

Use Cases: Developers commonly use the REST API for integrating Salesforce with external systems, creating custom web applications, and accessing Salesforce data from mobile devices.

SOAP API:

Purpose: The SOAP API provides robust support for enterprise-level integrations and complex data operations that require precise control and error handling.

Features: It uses the SOAP (Simple Object Access Protocol) protocol and offers a rich set of web services for interacting with Salesforce objects, metadata, and processes.

Use Cases: Organisations often use the SOAP API for integrating Salesforce with legacy systems, implementing complex business logic, and performing bulk data operations.

Bulk API:

Purpose: Designed specifically for processing large volumes of data efficiently, the Bulk API is ideal for batch data operations such as data loading, insertion, updating, and deletion.

Features: It supports parallel processing and batch processing to handle large data sets and maximise throughput.

Use Cases: Developers leverage the Bulk API for migrating data from external systems to Salesforce, performing periodic data imports, and executing data cleansing and deduplication tasks.

Streaming API:

Purpose: The Streaming API enables real-time data updates and event-driven architectures by delivering changes to Salesforce data in near-real-time.

Features: It uses a push technology to deliver events to subscribed clients, allowing developers to receive updates as they occur without polling.

Use Cases: Applications requiring real-time notifications, such as live dashboards, collaboration tools, and IoT (Internet of Things) integrations, benefit from the Streaming API’s capabilities.

In addition to these key APIs, Salesforce offers several other specialised APIs catering to specific use cases and requirements. Some notable examples include:

Chatter REST API:

Provides access to Chatter feeds, groups, users, and files for building social and collaboration applications.

Metadata API:

Allows developers to retrieve, deploy, create, update, or delete metadata components such as custom objects, fields, layouts, and Apex classes.

Tooling API:

Offers programmatic access to the Salesforce development environment for performing various development and administrative tasks.

Analytics API:

Facilitates access to Salesforce Analytics data for building custom analytics solutions and integrating with external BI (Business Intelligence) tools.

Each of these APIs serves a distinct purpose and offers unique capabilities to developers, empowering them to extend the functionality of the Salesforce platform and deliver innovative solutions tailored to their business needs.

Deep Dive into the Metadata API:

Among the diverse range of APIs provided by Salesforce, the Metadata API holds a unique position as a critical tool for managing customizations and configurations within Salesforce organisations. While other APIs primarily focus on data manipulation, the Metadata API deals with the metadata – essentially the “data about the data” – that defines the structure and behaviour of Salesforce objects, fields, workflows, and more.

Let’s delve deeper into the capabilities and functionalities offered by the Metadata API:

Retrieve Metadata Components:

1. The Metadata API enables developers to retrieve various metadata components that constitute the configuration of a Salesforce org. These components may include:

  • Custom objects and fields
  • Page layouts and record types
  • Apex classes and triggers
  • Workflows and approval processes
  • Reports and dashboards
  • Profiles, permission sets, and other security settings

By retrieving metadata components programmatically, developers gain insights into the current configuration of a Salesforce org and can perform analysis, documentation, or comparison tasks as needed.

2. Deploy Changes Across Environments:

  • One of the key strengths of the Metadata API is its ability to facilitate seamless deployment of changes across different Salesforce environments, such as sandbox environments and production orgs.
  • Developers can package metadata components into deployment packages (known as “metadata containers” or “metadata packages”) and deploy them using the Metadata API, ensuring consistency and reliability of configurations across environments.
  • This capability is particularly valuable for implementing continuous integration and continuous deployment (CI/CD) practices, automating release processes, and maintaining synchronisation between development, testing, and production environments.

3. Create, Update, or Delete Metadata Programmatically:

  • With the Metadata API, developers can programmatically create, update, or delete metadata components, empowering them to automate various development and deployment processes.
  • For example, developers can use the Metadata API to:
    • Create custom objects, fields, or validation rules dynamically based on business requirements.
    • Update existing metadata components to reflect changes in business processes or system integrations.
    • Delete obsolete or deprecated metadata components to maintain a clean and efficient Salesforce org.
  • This level of automation enhances productivity, reduces manual effort, and ensures consistency and accuracy in Salesforce configurations.

4. Implement Version Control and Release Management:

  • The Metadata API facilitates version control and release management for Salesforce configurations, enabling organisations to track changes, manage dependencies, and roll back deployments if needed.
  • Developers can integrate the Metadata API with version control systems like Git to maintain a centralised repository of metadata components, track changes over time, and collaborate effectively with team members.
  • By implementing version control and release management practices, organisations can enforce governance policies, ensure compliance with regulatory requirements, and mitigate risks associated with configuration changes in Salesforce.
  • A great example to demonstrate the capabilities of the Metadata API in action could be creating a custom Salesforce object programmatically and then deploying it across different environments using the Metadata API.

Example: Creating a Custom Object using the Metadata API

Objective : Create a Lookup Field inside the ‘Quote__c’ object where my custom field name and object is where my component has been placed.

Please refer below link and create all the apex class and its respective test apex in the org.

https://github.com/ShahPrincy/apex-mdapi-master

The apex which we used in this requirement, it must be implemented Metadata.DeployCallback.

Example 1

Below apex code is used to create a new lookup field in the ‘Quote__c’ object.

Example 2

@AuraEnabled

public static void createLookupFields (Id recordId, String currentObjectName) {

String objectLabel = recordId.getSObjectType().getDescribe().getLabel();

createLookUp(currentObjectName, objectLabel, UserInfo.getOrganizationId()+”+UserInfo.getSessionId().SubString(15));

}

@future(callout=true)

public static void createLookUp(String objectName, String objectLabel, String sessionId){

System.debug(‘objectName — ‘+ objectName);

System.debug(‘sessionId — ‘+ sessionId);

MetadataService.MetadataPort metadataPort = createService();

MetadataService.ProfileFieldLevelSecurity fieldLevelSecurity = new MetadataService.ProfileFieldLevelSecurity();

MetadataService.CustomField customField = new MetadataService.CustomField();

customField.fullName = ‘Quote__c.’ + objectName; // Generate a unique API name for each lookup field.

customField.type_x = ‘Lookup’;

customField.referenceTo = objectName;

customField.label = objectLabel; // Need Object Name (Not Label)

customField.relationshipLabel = ‘Quotes1’;

customField.relationshipName = ‘Quotes1’;

System.debug(‘customField — ‘+ customField);

MetadataService.SaveResult[] results = metadataPort.createMetadata(new MetadataService.Metadata[] { customField });

if (results[0].success) {

System.debug(‘Custom field created successfully.’);

}

}

Conclusion:

The Metadata API serves as a powerful tool for managing and customising Salesforce configurations, enabling developers to retrieve, deploy, create, update, and delete metadata components programmatically. By leveraging the capabilities of the Metadata API, organisations can streamline development processes, ensure consistency across environments, and effectively manage the lifecycle of Salesforce configurations.

Incorporating the Metadata API into your Salesforce development workflow can significantly enhance productivity, improve collaboration among development teams, and accelerate time-to-market for innovative Salesforce solutions. Reach out to NSIQ INFOTECH – best salesforce consulting company in India, to incorporate Metadata API into your Salesforce development workflow.

Maximizing Customer Engagement with Salesforce-WhatsApp Integration

WhatsApp free, Cross-platform, and VoIP (voice over IP) service owned by the Meta platform. WhatsApp is the most popular messaging app in the world with above 2 billion active users. What’s is best app because it’s available on various platforms including Android and iOS.

Salesforce is a cloud-based CRM (Customer Relationship Management). Salesforce CRM easily manages businesses and their customer interactions. It provides a single view of customers across all channels. Including sales, marketing, and service.

Salesforce is a CRM platform that helps business manage their customer relationship. By integrating Salesforce with WhatsApp, businesses will get power because of these two platforms together WhatsApp and salesforce.

WhatsApp with Salesforce integration allows communication sales, service, marketing, and commerce interaction.

Benefits of Integrating WhatsApp with Salesforce:

Improve Customer Engagement:

WhatsApp app is a popular messaging app with over 2 billion active users worldwide. After integrating WhatsApp with Salesforce, businesses can communicate with their customers. As a leading salesforce development company in USA, we integrate WhatsApp with salesforce to improve communication by reducing the number of support tickets as well.

Automated Messaging:

Automated messaging is a great way to improve customer engagement by providing timely and consistent responses to customer inquiries. The help of automating messages can help businesses to increase sales.

Increased Sales:

Businesses can use WhatsApp to promote their product and services, answer customer questions with provide customer support.

For Streamlined Communication:

Integrating WhatsApp with Salesforce in streamlined communication because of sending and receiving messages, scheduling appointments, sending reminders, and collecting feedback all things easily possible.

Features of Integrating WhatsApp with Salesforce:

Customer Support

à Integrating WhatsApp with Salesforce in customer support can help the business to provide a more efficient personalized customer experience. Some benefits of customer support are below:

  1. Improve customer satisfaction
  2. Increase efficiency
  3. Personalize communication
  4. Automate the tasks
  5. Improved data insights

Sales and Marketing

à Integrating WhatsApp with Salesforce for sales and marketing can help businesses to below:

  1. Track marketing result
  2. Automate marketing tasks
  3. Personalize marketing message

Timely Notification

à After integrating WhatsApp with Salesforce for timely notification can help businesses to:

  1. Automate notifications
  2. Personalized notification
  3. Task notification opens
  4. Send timely notifications to customers

Ex- any restaurant uses WhatsApp to send notifications to customers about current orders with the same update as well.

Automated response

à This integration is used to create responses for common queries such as:

Auto response can help businesses improve customer satisfaction by providing quick questions and answer

Ex –

  1. What is my account, Balance?
  2. When is my next appointment?
  3. How do I track my Order?

Personalized messaging

à Salesforce and WhatsApp integration allows businesses to personalize their messaging to customers. And personalize messaging have also benefits like increased customer engagement, Improved customer satisfaction, increased sales, reduced costs, increased efficiency.

Reduced cost: Personalized messages can help reduce costs by automating customer interactions and providing customers with the information they need.

Increased customer engagement: WhatsApp is the most popular app in the world with 2 billion active users. And help salesforce and WhatsApp integration to reach more customers.

Enhanced customer insights: The salesforce with WhatsApp integration gains the dippers insights into customer Behaviours’ and preferences. This information can be used to improve customer engagement. Overall integration between WhatsApp with Salesforce for personal messaging can provide no benefits as per above.

Ex – A healthcare provider could use WhatsApp with salesforce integration to send daily updates to patients meaning daily meals, and daily appointments, with patient questions and answers to improve patient care and satisfaction.

Automate the tasks: After integrating Salesforce with WhatsApp some benefits of automating tasks.

Improved efficiency: Automating tasks can help businesses save time.

Reduced Error: This can help businesses improve accuracy and consistency and reduce the coming errors.

Improved customer service: Automated tasks can help businesses to provide the better

Increase productivity: WhatsApp with salesforce integration in automating the task increases productivity. Automated tasks help to achieve the goals easily.

Here is one example of messaging between salesforce and WhatsApp

Maximizing Customer Engagement with Salesforce-WhatsApp Integration

Example of messaging between salesforce and WhatsApp

One of the most popular communication apps is WhatsApp and the best CRM is Salesforce integration as shown above WhatsApp offers business API that helps us integrate with Salesforce. API is basically used for the communication and interaction between WhatsApp and Salesforce. Integration with Salesforce requires some bridge so we write some custom code for this.

FAQ:

1. What are the requirements for integrating WhatsApp with Salesforce?

  • The requirements for integrating WhatsApp with Salesforce are below:
  • You must have a WhatsApp business account and a verified Facebook Business Manager Account.
  • You have the must permission to configure messaging in Salesforce.
  • You must have the provider’s permission to authorize WhatsApp Messaging Customize application.
  • You must have a view setup and must configure it to see WhatsApp channels.

2. How long does it take to integrate WhatsApp with Salesforce?

  • It sometimes takes to integrate WhatsApp with Salesforce and it depends on a number of factors, including the complexity of your integration.
  • Some general timelines are below for the integration of WhatsApp with Salesforce.
  • 1 – 2 weeks: Gather the requirements and plan the integration
  • 2 – 4 weeks: Develop and test integration.
  • 1 – 2 weeks: Deploy the integration.

Conclusion:

Integrating WhatsApp with Salesforce can great way to increase sales, and streamline communication, and customer engagement through automated the tasks.

Integration of DocuSign with Salesforce

DocuSign Is an electronic signature and agreement management platform. The DocuSign salesforce integration offers a number of benefits, especially to a salesforce consultant in India.

Benefits of Integrating DocuSign with Salesforce

1. Reduced Risk 

Electronic signatures are legal in most countries, and DocuSign is the best platform it provides a number of features with the security, help of DocuSign to protect data and documents.

2. Increased Productivity

DocuSign salesforce increases productivity which means using automation, bulk sending, salesforce integration, using the DocuSign mobile app.

Integration of DocuSign with Salesforce

Below are some specific examples of DocuSign Salesforce

  • use the bulk-sending features in DocuSign to send the same NDA to all of the vendors that you are working with on a new object.
  • Use DocuSign mobile app to sign a contract with a customer while you are at a meeting.

3. Improved Customer Satisfaction

As a trusted salesforce development company in India, we use a number of ways to improve customer satisfaction. Some of them are:   

  • Resolve customer issues quickly and efficiently.
  • Use customer feedback to improve the process.
  • Make it easy for customers to sign agreements.

Benefits of Integrating DocuSign with Salesforce

Here below are some specific examples of how DocuSign salesforce improved customer satisfaction.

         3.1.1 used DocuSign e-signature API to automate the agreement process.

         3.1.2 use the DocuSign mobile app to allow customers to sign agreements from anywhere anytime

         3.1.3 use the DocuSign dashboard to track the status of agreements and to identify areas where you can improve your process.

How does DocuSign work?

DocuSign is an electronic signature platform, that helps DocuSign users send sign, and manage documents electronically. Basically, DocuSign is the fast and reliable way to electronically sign documents and easily manage them, you can have all your documents digitally signed whatever you want. DocuSign is very easy to handle and is best for us to get signatures.

Benefits of DocuSign:

  1. Easy file sharing and access.
  2. Streamlined document signing process.
  3. Time-saving automation of business processes.
  4. Access from Any device
  5. Enhanced security
  6. Enhanced verification
  7. Ability to store
  8. Integration with other software programs
  9. User-friendly interface and design
  10. Ability to send reminders 

Limitation of DocuSign:   

DocuSign is a powerful signature platform but DocuSign also have some limitations.

1. Number of Documents Per Envelope 

DocuSign has some limit about documents per envelope which means 130 unique documents per envelope.

2. Supported File Format

DocuSign supports a variety of file formats but some common formats include PDF, word, excel, and PowerPoint.

3. Integration with Other Software

DocuSign is integrated with different types of software but not for all types of software.

4. File Size Limit 

DocuSign has a limit on the size of files that can be uploaded and signed. 

How use DocuSign?

  • Step – 1 -> Upload your document
  • Step – 2 -> Follow the DocuSign tabs
  • Step – 3 -> then place the field and send
  • Step – 4 -> sign in automatically
  • Step – 5 -> Your Document is saved automatically and securely
  • Step – 6 -> Finish here 

FAQ:

1. What is DocuSign?

DocuSign is an electronic signature platform that helps users send, sign, and manage Documents electronically.

2. Is DocuSign being secure?

Yes, DocuSign is secure. DocuSign uses a digital signature to ensure the security of signed documents.

3. How much does DocuSign cost?

Basically, DocuSign offers a free plan for individuals who need to sign a limited number of documents per month. and DocuSign also offers different types of paid plans for businesses of all sizes. DocuSign is paid for per much required only.

4. What types of documents can I sign with DocuSign?

you can use a variety of documents with DocuSign, including contracts, purchase orders, and employment agreements.

5. Where is DocuSign is available?

DocuSign is available in over 180 countries around the world.

6. How do I sign the Document?

When the user receives a DocuSign Document to sign, you will receive an email with a link to the document.

7. I have a question about DocuSign that is not answered in the FAQ. Where can I get help?

If you have a question about DocuSign that is not answered in the FAQ, you can contact DocuSign for assistance.

8. Can I sign a document on my mobile device?

Yes, you can sign documents with DocuSign on your iPhone, iPad, or Android devices. If you want to use the signed document, move to the app store, Google Play, and download from there.

9. DocuSign is legal? 

Yes, DocuSign is legal in most of countries

Conclusion:

DocuSign is the best electronic signature platform because it is easy to use, secure reliable. It is used for all type and size of business and if need sign and send securely then DocuSign is best option for you.

Google Drive Integration with Salesforce

Salesforce to Google Drive Integration extends the power of G Drive to your CRM. It enables real-time synchronization and complex business process optimization. Our Salesforce CRM Integration Services allows users to spend more time building relationships with customers instead of wasting time on manual tasks. It allows team collaboration in the context of the customer by attaching Sheets, Docs and Slides to an opportunity, account or customer contact in Salesforce. Salesforce to G Drive integration is the need of various industries as Salesforce analyses data and generates reports.

Google Drive Integration with Salesforce

Overview

Our organization heavily relies on Salesforce for managing customer data and generating various reports to monitor sales, customer interactions, and business performance. As a salesforce integration service consultant in USA, we have also been using Google Drive as a centralized platform for document storage and collaboration. To streamline our operations and improve efficiency, we need to integrate Salesforce Reports directly with Google Drive.

Problem Statement

Currently, our sales and marketing teams manually download Salesforce Reports from the system and upload them to Google Drive. This process is time-consuming, prone to human errors, and can lead to data discrepancies. As a prominent Salesforce Consultant in USA, we seek to automate this process by developing a seamless integration between Salesforce and Google Drive.

Google Drive Integration Steps

  1. create project in google cloud console
  2. create Credentials
  3. Install Google Drive library
  4. create configurations
  5. create remote site settings
  6. create new folder in your google drive for store file.
  7. Http callout for google drive integration

Step 1:  Create a Google Cloud Project

first navigate this URL for create project in google cloud console

https://console.cloud.google.com

After redirect this URL you need to login with your Gmail Account

A Google Cloud project is required to use Google Workspace APIs and build Google Workspace add-ons or apps. This project forms the basis for creating, enabling, and using all Google Cloud services, including managing APIs, enabling billing, adding and removing collaborators, and managing permissions.

To create a Google Cloud project:

  1. In the Google Cloud console, go to Menu > IAM & AdminCreate a Project.
  2. In the Project Namefield, enter a descriptive name for your project.

Step 2:  Create Access Credentials

In the Google Cloud console, go to Menu > APIs & Services > Credentials.

Click Create Credentials > OAuth client ID.

In the Name field, type a name for the credential. This name is only shown in the Google Cloud console.

Add authorized URIs related to your app:

  • Client-side apps (JavaScript)–Under Authorized JavaScript origins, click Add URI. Then, enter a URI to use for browser requests. This identifies the domains from which your application can send API requests to the OAuth 2.0 server.
  • Server-side apps (Java, Python, and more)–Under Authorized redirect URIs, click Add URI. Then, enter an endpoint URI to which the OAuth 2.0 server can send responses.

  • Click Create. The OAuth client created screen appears, showing your new Client ID and Client secret.
  • Click OK. The newly created credential appears under OAuth 2.0 Client IDs.

Step 3:  Install Google Drive Library

Click on library option

In serach bar find google drive API

Click on Google drive API, then click Enable button

Step 4:  Create Configurations

Click on Quick find box -> Search custom setting -> New

then create custom fields given by image

Step 5:  Create Remote Site Settings

Click on Quick find box -> Search remote site settings -> New remote site

You need to create two custom setting and add this URL

https://accounts.google.com

https://www.googleapis.com

Step 6:  Create New Folder in Your Google Drive for Store File

Go to your Google Drive -> click on New -> New Folder

Step 7:  HTTP Callout for Google Drive Integration

First time authorize your Gmail account using redirect URL

String key = ‘use your client id here’;

String uri= ‘use your authorize URL here’;

String authuri = ”;

authuri = ‘https://accounts.google.com/o/oauth2/auth?’+

‘client_id=’+key+

‘&response_type=code’+

‘&scope=https://www.googleapis.com/auth/drive’+

‘&redirect_uri=’+uri+

‘&state=security_token%3D138r5719ru3e1%26url%3Dhttps://oa2cb.example.com/myHome&’+

‘&login_hint= jsmith@example.com&’+

‘access_type=offline’+

‘&prompt=consent’;

HTTP callout for first time get access token

HttpRequest req = new HttpRequest();

req.setMethod(‘POST’);

req.setEndpoint(‘https://accounts.google.com/o/oauth2/token’);

req.setHeader(‘content-type’, ‘application/x-www-form-urlencoded’);

//String messageBody =’GoogleSheetIntegration’+’&grant_type=client_credentials’;

String messageBody = ‘code=’+code+’&client_id=’+clientId+’&client_secret=’+clientsecretId+’&redirect_uri=’+redirectURL+’&grant_type=authorization_code’;

req.setHeader(‘Content-length’, String.valueOf(messageBody.length()));

req.setBody(messageBody);

req.setTimeout(60*1000);

system.debug(‘Access token request–‘+req);

Http h = new Http();

HttpResponse res = h.send(req);

HTTP callout for Refresh access token

Strrng  clientId  =  ‘use your client id’ ;

Strrng  clientSecretId =  ‘use your client Secret id’;

String  refreshToken = ‘use refresh token it is given when first time get access token’;

String bodyRequest = ‘client_id=’ + clientId;

bodyRequest += ‘&client_secret=’ + clientSecretId;

bodyRequest += ‘&refresh_token=’ + refreshToken;

bodyRequest += ‘&grant_type=refresh_token’;

Http http = new Http();

HttpRequest req = new HttpRequest();

req.setMethod(‘POST’);

req.setEndpoint(‘https://accounts.google.com/o/oauth2/token’)

req.setHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’);

req.setBody(bodyRequest);

// Send the HTTP request

HttpResponse res = http.send(req);

HTTP callout for Export file in Google drive

Report report = [SELECT Id,DeveloperName,Name FROM Report where DeveloperName  =  ‘New_Contacts_Accounts_Report_1_UmO’];

ApexPages.PageReference reportPage = new ApexPages.PageReference(‘/’+report.Id+’?excel=1&isdtp=p1′);

Messaging.EmailFileAttachment csvAttachment = new Messaging.EmailFileAttachment();

csvAttachment.setFileName(‘Report.xls’);

csvAttachment.setBody(reportPage.getContent());

csvAttachment.setContentType(‘application/vnd.ms-excel’);

String fileName = ‘GoogleDriveReportForAccount.xls’;

Blob fileData = reportPage.getContent();

String parentFolderId = ‘XXXXXXXXXXXXXXXXXXXXXXXX’; // use your google drive folder Id here

HTTP callout for create excel file

String endpointUrl = ‘https://www.googleapis.com/drive/v3/files’;

HttpRequest request = new HttpRequest();

request.setEndpoint(endpointUrl);

request.setMethod(‘POST’);

request.setHeader(‘Content-Type’, ‘application/json’);

request.setHeader(‘Authorization’, ‘Bearer ‘ + accessToken);

Map<String, Object> requestBody = new Map<String, Object>();

requestBody.put(‘name’, fileName);

requestBody.put(‘mimeType’, ‘application/vnd.ms-excel’);

requestBody.put(‘parents’, new List{parentFolderId}); //

String requestBodyJson = JSON.serialize(requestBody);

request.setBody(requestBodyJson);

HttpResponse response = new Http().send(request);

HTTP callout for upload file in your google drive

Note:  fileId available in create file HTTP callout response

String endpointUrl = ‘https://www.googleapis.com/upload/drive/v3/files/’ + fileId + ‘?uploadType=media’;

HttpRequest request = new HttpRequest();

request.setEndpoint(endpointUrl);

request.setMethod(‘PATCH’);

request.setHeader(‘Content-Type’, ‘application/vnd.ms-excel’);

request.setHeader(‘Authorization’, ‘Bearer ‘ + accessToken);

request.setBodyAsBlob(fileData);

HttpResponse response = new Http().send(request);

A Complete Guide to Email Studio and Journey Builder

Email Studio:

It’s a powerful email marketing tool that harness the power of data and automation to craft high-value customer relationship. You can leverage email studio to automate transactional communication or send personalized email message to target groups.

  • In Email Studio there is four features.
  1. Content
  2. Subscribers
  3. Interaction
  4. A/B Testing

We talk about Subscriber’s Data extension Section and Journey Builder:

Subscribers:

A subscribers is a person who has opted to receive communication from your organization. You must have a valid email address for each subscribers who receives emails. For each subscribers who receives SMS messages, you must have a valid phone number. Its data which will handling the emails for MC. In subscribers there is five section like My Subscribers, Data Extension, Salesforce Data Extension, Synchronized data Extension, Shared Data Items.

Data Extension:

A data extension is a feature that allows you to store and manage additional data related to your subscribers. It provides a way to extend the default subscriber attributes and capture custom information specific to your business needs.

Data Extensions are typically linked to subscribers within Marketing Cloud. This linkage allows you to associate the custom data stored in Data Extensions with specific subscribers. It facilitates personalized email content and segmentation based on the additional data captured.

Overall, Data Extensions in Email Studio provide a flexible and customizable way to store and manage additional subscriber data beyond the default attributes. As a prominent salesforce development company in India, we use data extensions to enhance the ability to personalize email campaigns, segment audiences, and capture relevant information specific to the marketing goals and strategies.

Journey Builder:

Journey Builder is a powerful feature within Salesforce Marketing Cloud that allows marketers to create and automate personalized, multi-channel customer journeys. It provides a visual interface and a set of tools to design, execute, and track customer journeys across various touchpoints, such as email, SMS, mobile push notifications, social media, and more.

There is a three creation types of Journey builder,

    1. Multi-Step Journey
    2. Single Send Journey
    3. Transactional Send Journey

Multi-Step Journey :

Journey Builder’s Multi-Step journeys enable you to create and manage customer journeys through a series of interactions with your brand. These journeys can include multiple channels and customized journey paths based on customer interactions or attributes.

They can include various touchpoints such as email, SMS, mobile push notifications, social media ads, and more.

Marketers can use decision splits, personalization, and automation to create highly targeted and personalized experiences for each customer.

Single Send Journey:

Single Send journeys enable you to create and manage simple, one-touch customer journeys within the same workspace used for Multi-Step journeys. Define the target audience for the entry source, add existing message content or create a message from scratch, and send or schedule the send for a later date and time.

These journeys involve a single action, such as sending an email, and do not have multiple stages or complex branching logic.

Single-send journeys are relatively quick to set up and execute, making them suitable for time-sensitive or ad hoc campaigns.

Transactional Send Journey:

Transactional Send journeys enable you to create and manage transactional API messages in the same Journey Builder workspace used to manage Single Send and Multi-Step journeys. This journey type allows non-technical users to configure a Transactional API entry source without assistance from a developer. You can also monitor journey performance, such as error counts and queue depth, from the Journeys Dashboard.

In this blog we can see some real scenario of how to use Email Studio and Journey Builder to send the welcome Email to all subscribers which will in data extension.

  1. Create Data Extension in Email Studio: You have to first create data extension for all subscriber details in email studio.
    1. Log in into your Marketing cloud org and in this go into Email studio and select the Subscribers.
    2. In subscribers select the Data Extension and create new data extension. You have to select the method by which the data extension will be built.
    3. There are three types of data extension like standard, filtered and random. If you want to create new data of subscribers then select the standard and filtered data extension.
    4. Now, gave the name of data extension and create the fields that you want to for your subscriber details and in the send relationship you have to select any field as a subscriber key or subscriber Id. click done.
    5. Your new created data extension will look like that.
    6. Now, you have to add records in this data extension. For adding new data in data extension select the Import button and select the file from your browser and click next.
    7. After, selecting the file from your browser now you have to map the fields between the file which you import and fields that you create in data extension. You can map the fields by header row, ordinal and manually.
    8. After, mapping the fields now click next and in email address add your email address so, it will send a email after the import process will complete. Now, click import and you can see the records will imported in your data extension.
  • After, completing all this steps now you have to send the welcome email to your data extension’s all subscribers.

Create Journey in Journey Builder:

You have to create a journey builder to send the welcome email to subscribers.

    1. Go in to the journey builder and create new journey.
    2. You can select the journey type as per your needs. Here, we can select the Multi-Step journey select it and click create.
    3. Now, in the entry source select the data extension and in this select the data extension which you will create before and click done.
    4. In the schedule section select the Run Once type so your journey will run at a time when you activate it.
    5. Now, select the Email activity. In this you have to select the email message which you have to send to your subscribers.
    6. After, that in wait activity select the duration as per your needs here we can select the 1 day and click Activate.
    7. Finally, after completing all these steps your data extension’s subscribers will receive a welcome email. It’s looks like that.

Integration Between Salesforce Sales Cloud and Marketing Cloud

Overview:

Marketing Cloud is mainly used for maintaining the customer information for sending email and tracking customer activity. With salesforce marketing cloud services, you can send emails directly from Salesforce via Marketing Cloud Connector and this email information is tracked in Salesforce. Integration is completed by mapping user from Marketing Cloud to Salesforce. To achieve successful integration between Marketing Cloud and Salesforce, please follow the steps below:

Integration Steps and Considerations:

Installing Marketing Cloud Connector Package:

  1. First, you should install the Marketing Cloud Package in your Salesforce sales cloud org.
  2. Use the following URL for the package installation.
    Production org:  https://sfdc.co/MCC
    Sandbox org:  https://sfdc.co/MCCSandbox
  3. Login to your salesforce sales cloud account using your admin credentials and then select Install Admins only and click Install.salesforce marketing cloud services
  4. Click the checkbox for “Yes, grant access to these third-party web sites”.salesforce marketing cloud services
  5. Click Continue and After that, you should receive an email like the Marketing Cloud Connector Package was installed successfully.
  6. The managed package should show up in your Installed package under Setup > Apps > Packaging > Installed Packages. The Package name is Marketing cloud.
  7. After installing the package, you will need to gave some permissions and access.

Modify Page Layouts:

  1. Add this two ‘Marketing Cloud for AppExchange User’ and ‘Marketing Cloud for AppExchange Admin’ in User Page Layout additional information and enable both checkboxes. Also, ensure the profile has the ‘API Enabled’ permission. salesforce marketing cloud services
  2. In Lead page layout add ‘Email sends’ and ‘Individual Email Result’ in related list and select visual force page and add the lead action in description information. Do the same steps for Contact object page layout.salesforce marketing cloud services
  3. Select the ‘Marketing Cloud for AppExchange User’ and ‘Marketing Cloud for AppExchange Admin’ In additional information in your sales cloud user.
  4. Next, in Lead object and Contact object select the Email opt out field and in this select the field-level security and check the checkbox in visible for Marketing user profile.
  5. Now, create one permission set and assign this permission set to your sales cloud user. You have to create this permission set only for connection and authentication.

Configure the Marketing Cloud Connection

  1. In Marketing cloud gave the two roles to your MC user.
  • Administrator
  • Marketing Clous Administrator
  1. Now, in quick find box search salesforce Integration and click connect account, in this enter your sales cloud username and password.salesforce marketing cloud servicessalesforce marketing cloud services
  • You just created the handshake between Marketing Cloud and your CRM org. That established a connected app relationship inside Salesforce CRM.
  1. Go back to your sales cloud org and in quick find box search connected app. In this select the salesforce marketing cloud and click edit policies. In Permitted Users select Admin approved users are pre-authorized, In IP Relaxation select Relax IP restrictions and select the Immediate expire refresh token.salesforce marketing cloud services
  1. Scroll down to the page and in Manage permission set select the permission set which you will create before.
  2. Type Process Automation in quick find box and select the process automation setting. If the Default Workflow User is empty, click the lookup icon and specify a user with System Administrator permissions to be the default workflow user.salesforce marketing cloud services
  1. Next type Session Settings in the Quick Find box and click Session Settings, Scroll down to the bottom of the page and click Save.

Yes, that’s right, You don’t actually change any settings, but this is a necessary step for the configuration. If this step is not performed, the managed package wizard is not able to add IP allowlisting.

Marketing Cloud Connector Setup Wizard:

  1. In you sales cloud org go into the app launcher and in this select the Marketing cloud and there is the popup screen populated in this click the verify remote site and click ok.salesforce marketing cloud services
  1. In next popup screen is about for Metadata API. Click start wizard to begin the setup wizard.salesforce marketing cloud services
  1. Click Next to move forward and acknowledge you’ve saved the Session Security Settings.
  2. Click Next to acknowledge Field-Level Security information.
  3. Click Done to acknowledge the page layout update information.
  4. At the main Marketing Cloud Connector Setup screen, select I agree to acknowledge the automated changes and then click Configure Marketing Cloud Connector.salesforce marketing cloud services
  1. Click Okay! to finish the setup wizard.

Connect to Marketing cloud within Salesforce CRM:

  1. In sales cloud org, go into the app launcher and in this select the Marketing cloud Click the connect to marketing cloud an enter your username and password and click login.salesforce marketing cloud services
  2. If successful, you see a screen to configure Marketing Cloud Connect settings. Under the Account section on the page, select Email.salesforce marketing cloud services
  1. In the Sends section, select all options.
  2. In the triggered sends select the all option and in the notification section enter the appropriate email address to receive any error messages from Marketing Cloud Connect.salesforce marketing cloud services
  1. In the Tracking section, select appropriate options for your organization about the specific email tracking data that Marketing Cloud sends to the CRM system. Keep in mind that the choices you make for these can affect the overall storage of your CRM org.
  2. Click save setting and select at least one business unit from the Business Unit Management screen and click Save.

Marketing Cloud User Integration:

  1. In Marketing Cloud, hover over your name and select Setup.

In setup select user and in the salesforce.com status click integrate and enter your username for the CRM API user and click save setting.
salesforce marketing cloud services

  1. If successful, the Salesforce.com Status updates to Integrated.

Finally, after completing all these step you can successfully integrate sales cloud with marketing cloud.

How to Integrate Slack with Salesforce: A Guide to Streamlining Your Business Processes

Collaboration tools have become essential in today’s workplace. Slack and Salesforce are two of the most popular tools used by businesses. Integrating Slack with Salesforce can improve communication, streamline workflows, and increase productivity.

Why Integrate Slack with Salesforce?

Integrating Slack with Salesforce offers many benefits, such as:

Improved Communication:

Sales reps can receive real-time updates on leads and opportunities in Slack. They can also communicate with their team members directly in Slack, without having to switch between different tools.

Streamlined Workflows:

Support teams can create cases and assign them to team members directly from Slack. This reduces the time it takes to create a case and ensures that the case is assigned to the right team member.

Increased Productivity:

A salesforce integration service consultant in USA suggests Integrating Slack with Salesforce as it eliminates the need for manual data entry, which can be time-consuming and prone to errors. This allows teams to focus on more important tasks.
Requirement: My requirement is to create a new event for an account in Salesforce when a new message is generated in a Slack channel with the same name as the account record. To do this, I will need to integrate Slack with Salesforce.
Solution: In my requirement, I will create an Apex class that is triggered at specific intervals, such as every hour or half hour. When the class runs, it should fetch all new messages in a Slack channel that arrived during that particular interval.

  1. The first step in the integration process is to create a new app in Slack. To do this, visit https://api.slack.com/apps and create a new app. Slack will provide you with a Client ID and Client Secret Key, which you will need in the further steps of the integration process.

app credentials
In addition, you will need to set the appropriate scope for the app in the OAuth & Permissions section of the app settings. This will ensure that the app has the necessary permissions to access and modify the data in your Slack workspace and Salesforce org.
Bot Token Scopes

  1. channels:history
  2. channels:read
  3. cconnect:read
  4. groups:history
  5. groups:read
  6. im:history
  7. im:read
  8. mpim:history
  9. mpim:read

User Token Scopes

  1. channels:history
  2. channels:read
  3. groups:history
  4. groups:read
  5. im:history
  6. im:read
  7. mpim:history
  8. mpim:read

This slack app also provides you with a User OAuth Token which will be used in further steps.
user oauth token
The first step is to obtain all channel IDs from Slack because we want the message to arrive in any Slack channel that is used in Salesforce.
To do this, we need to use the SLACK_API_TOKEN variable, which is the Slack API token that you obtain from the Slack app. We can make HTTP requests to obtain all channel IDs from Slack.
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setMethod(‘GET’);
req.setEndpoint(‘https://slack.com/api/conversations.list’);
req.setHeader(‘Authorization’, ‘Bearer ‘ + SLACK_API_TOKEN);
req.setHeader(‘Content-Type’, ‘application/json’);
HTTPResponse res = http.send(req);
Map<String, Object> responseMap = (Map<String, Object>) JSON.deserializeUntyped(res.getBody());
Listchannels = (List) responseMap.get(‘channels’);We can use a list to store all the channel IDs from Slack.Next, we need to write Apex code to store this Slack channel data from an account object or any other custom object.After obtaining the channel IDs, we need to get the channel names from Slack. To do this, we need to make an HTTP callout to get the Slack channel names.Map<String, Object> infoParams = new Map<String, Object> {‘channel’ => channelId,’token’ => apiToken};Http http = new Http();HttpRequest infoRequest = new HttpRequest();infoRequest.setEndpoint(‘https://slack.com/api/conversations.info’);infoRequest.setMethod(‘GET’);infoRequest.setHeader(‘Authorization’, ‘Bearer ‘ + SLACK_API_TOKEN );infoRequest.setTimeout(60000);String infoBody = ”;for (String key : infoParams.keySet()) {if (infoBody.length() > 0) {infoBody += ‘&’;}infoBody += key + ‘=’ + String.valueOf(infoParams.get(key));}infoRequest.setBody(infoBody);HttpResponse infoResponse = http.send(infoRequest);string channelName;Map<String, Object> infoData = (Map<String, Object>) JSON.deserializeUntyped(infoResponse.getBody());Map<String, Object> channel = (Map<String, Object>) infoData.get(‘channel’);channelName = (String) channel.get(‘name’);As a prominent salesforce consultant in USA, we schedule our Apex class to run every half hour so that the below code can get any new messages that arrive in any Slack channel. You need to call the below code for each Slack channel you want to monitor.Datetime currentTime = Datetime.now();Datetime fiveMinutesAgo = currentTime.addMinutes(-30);String fiveMinutesAgoTimestamp = String.valueOf(fiveMinutesAgo.getTime()/1000);String channelMessages = ”;Map<String, Object> historyParams = new Map<String, Object> {‘channel’ => channelId, // Pass Your slack channel Id’limit’ => 1000,’inclusive’ => true,’token’ => apiToken,’oldest’ => fiveMinutesAgoTimestamp};Http http = new Http();HttpRequest historyRequest = new HttpRequest();historyRequest.setEndpoint(‘https://slack.com/api/conversations.history’);historyRequest.setMethod(‘GET’);historyRequest.setHeader(‘Authorization’, ‘Bearer ‘ + SLACK_API_TOKEN );historyRequest.setTimeout(60000);String historyBody = ”;for (String key : historyParams.keySet()) {if (historyBody.length() > 0) {historyBody += ‘&’;}historyBody += key + ‘=’ + String.valueOf(historyParams.get(key));}     historyRequest.setBody(historyBody);HttpResponse historyResponse = http.send(historyRequest);Map<String, Object> historyData = (Map<String, Object>) JSON.deserializeUntyped(historyResponse.getBody());Listmessages = (List) historyData.get(‘messages’);
String channelMessages;
for (Object message : messages) {
Map<String, Object> messageData = (Map<String, Object>) message;
channelMessages = channelMessages + ‘-‘ +(String) messageData.get(‘text’);
}
You now need to update the account object record with the same name as the Slack channel and utilise its field to create event data based on the Slack channel message

Salesforce AppExchange Security Review

What is salesforce security?

The Salesforce Security model assists you in protecting information at various levels, from an org level down to a personal record. The Organization, Objects, Records, and Fields are the logical tiers of security. While using the model allows users to safeguard the organization’s information at four layers.

We will cover how to enforce data security and how to prevent SOQL injection attacks in Apex. We’ll also review what Locker Service does for you and security best practices for LWC. We will also cover some security in Salesforce interview questions for the apex.

Why does salesforce security need in your code?

The Salesforce Security Features Developed by a Salesforce Application Development Company Can Assist You in Empowering Your Users To Do Their Jobs Safely And Efficiently. Salesforce Limits The Exposure Of Data To The Users.

User Mode vs System Mode

System mode means running apex code by ignoring the user’s permissions. like Apex Classes, Apex Triggers, and Apex Services.
User mode means running apex code by respecting the user’s permissions and sharing of records. Let’s understand it in more detail.

List of Component  for applying salesforce security in below

  • Apex class Security
  • Application Security
  • Lightning Web Component Security
  • Visualforce page Security

Security in apex class 

Enforcing Object & FLS Permissions in Apex
Apex doesn’t enforce object-level and field-level permissions by default. Let’s see how we can enforce the CRUD & FLS in Apex.

Read data (SOQL) Modify data (DML)
Schema methods Yes Yes
WITH SECURITY_ENFORCED Yes No
Security.stripInaccessible() Yes Yes
Database operations in user mode (pilot) Yes Yes

Schema Methods
You can also enforce object-level and field-level permissions in your code by explicitly calling the sObject to describe result methods.

CRUD

You can call the isAccessibleisCreateable, or isUpdateable methods of Schema.DescribeSObject -Result to verify whether the current user has read, create, or update access to an sObject.

  • Schema.sObjectType.Account.isAccessible() – before querying

For example :

  • Schema.sObjectType.Account.isCreateable() – before inserting

For example :

  • Schema.sObjectType.Account.isUpdateable() – before updating

For example :

  • Schema.sObjectType.Account.isDeletable() – before deleting

For example :

Field Level Security

You can use the below method to check field-level security before querying.

  • Schema.sObjectType.Contact.fields.Status__c.isAccessible()
  • Schema.sObjectType.Contact.fields.Status__c.isCreateable()
  • Schema.sObjectType.Contact.fields.Status__c.isUpdateable()

For example:   

WITH SECURITY_ENFORCED

Use the WITH SECURITY_ENFORCED clause to enable field- and object-level security permissions checking for SOQL SELECT queries in Apex code.
It Checks for both CURF & FLS.
For example:

Security.stripInaccessible()

Use the stripInaccessible method to enforce field- and object-level data protection. This method can be used to strip the fields and relationship fields from query and subquery results that the user can’t access. The method can also be used to remove inaccessible sObject fields before DML operations to avoid exceptions and to sanitize sObjects that have been deserialized from an untrusted source
The Id field is never stripped
SObjectAccessDecision securityDecision = Security.stripInaccessible(AccessType, sourceRecords);
Contact ctc = securityDecision.getRecords()[0]; System.debug(CTC.isSet(‘social_security_number__c’)); // prints “false”

User mode database operations (Pilot)

CRUD, FLS and sharing New parameter on:

  1. Database.query methods
  2. Search.query methods
  3. Database DML methods (insert, update, upsert, delete)

Apex generally runs in system context meaning current user’s permissions and field-level security take place during code execution. Our Apex code should not expose the sensitive data to the User which is hidden via security and sharing settings. Hence, Apex security and enforcing the sharing rule is most important. Let’s see how we can enforce the sharing in Apex.

Not related to CRUD or FLS!!!!

Sharing Enforced
With sharing Yes
Without sharing No
Inherited  sharing Inherit from parent, with sharing if entry point
No sharing clause Inherited from parent,
Without sharing if entry point except for lightning

With Sharing Keyword

If you use this keyword, then the Apex code will enforce the Sharing settings of the current user to Apex code. This does not enforce the Profile permission, only the data level sharing settings.
For example:

Without Sharing Keyword

Class declared with this keyword executes in System mode.
For example :

Enforcing the current user’s sharing rules can impact:

  • SOQL and SOSL queries. A query may return fewer rows than it would operate in system context.
  • DML operations. An operation may fail because the current user doesn’t have the correct permissions

Bulkify Apex Code

The very first principle is to write code for more than one record at a time. We should write scalable code and avoid hitting the governor. Let’s understand with an example. In the code below we are using a hard Coded Index[0]. Means code will only work on single record
Solution
In the above Trigger, the code explicitly accesses only the first record in the trigger.new collection by using the syntax Trigger.New[0]. Instead, the trigger should properly handle the entire collection of Accounts using Trigger.new collection.
For example :
Trigger AccountTrigger on Account(before insert){
for(Account acc: trigger.New){
if(acc.Name != null){
// DO something
}
}
}

Avoid SOQL & DML inside for Loop

Do not place SOQL or DML(insert/update/delete/undelete) statements inside a loop. When these operations are placed inside a for loop, database operations are invoked once per iteration of the loop making it very easy.
For example:
Map<Id, Account> accountMap=new Map<id, Account>([select id,name, (select id from contacts) from account where id in:trigger.newmap.keyset()]);
for(Account acc: accountMap.values()){
for(Contact con:acc.Contacts){
}
}

Use of the Limits Apex Methods

Use Apex Limits Methods to Avoid Hitting SF Governor Limits. Many of us are facing governor limit errors in trigger/classes/test classes. Few of the governor limit errors as follow:-

  1. Too many SOQL queries: 101
  2. Dml rows 10001
  3. Too many query rows 50001.

For example:

Now, using the above Limit methods we can check how many SOQL queries we can issue in the current Apex Context

If(Limits.getLimitQueries() – Limits.getQueries()>0) {
// Execute SOQL Query here.
}

Exception Handling in Apex Code

DML statements return run-time exceptions if something went wrong in the database during the execution of the DML operations. Don’t forget to use Try catch blocks for exception handling. With Apex, you can write code that responds to specific exceptions.
For example:

System.runAs()

Only for Test Mode
Enforces sharing, not CRUD or FLS
For example: 
@isTest
private class TestRunAs {
public static testMethod void testRunAs() {
// Setup test data
// Create a unique UserName
String uniqueUserName = ‘standarduser’ + DateTime.now().getTime() + ‘@testorg.com’;
// This code runs as the system user
Profile p = [SELECT Id FROM Profile WHERE Name=’Standard User’];
User u = new User(
Alias = ‘standt’,
Email=’standarduser@testorg.com’,
EmailEncodingKey=’UTF-8′,
LastName=’Testing’,
LanguageLocaleKey=’en_US’,
LocaleSidKey=’en_US’,
ProfileId = p.Id,
TimeZoneSidKey=’America/Los_Angeles’,
UserName=uniqueUserName
);
System.runAs(u) {
// The following code runs as user ‘u’
System.debug(‘Current         User: ‘ + UserInfo.getUserName());
System.debug(‘Current Profile: ‘ +                 UserInfo.getProfileId());
}
}

Application Security

When queries are built directly with user data inlined or query text, instead of using type-safe bind parameters, malicious input may be able to change the structure of the query to bypass or change application logic. This is called a SOQL injection attack.
Preventing SOQL Injection
There is the following way available in Salesforce to prevent SOQL Injections.

  • Use static queries
  • If need to use dynamic queries, always bind user input with “:”
  • If not possible, escape typecast or whitelist inputs

Using static SOQL:

Account[] accts = [SELECT Name, Phone FROM Account];

If need to use dynamic queries, always bind user input with “:”

public static List getAccount(String searchValue) {
String likeValue = ‘%’ + searchValue + ‘%’;
return (List) Database.query(
‘SELECT Name FROM Account WHERE Name LIKE :likeValue’
);
}

Escape Single Quotes / Typecasting

If not possible, escape typecast or whitelist inputs

Escape Single Quotes:

Typecasting like below:

  • Reflected XSS → app echoes malicious script from user input
  • Stored XSS → app returns malicious script from database
  • DOM XSS → reflected XSS but just on the browser

Locker Service

  1. JavaScript Strict mode enforcement
  2. DOM access containment → Safe Harbour: mechanism to relax this restriction
  3. Secure wrappers → sfdc.co/locker-api-viewer
  4. CSP → sfdc.co/locker-csp

Security in LWC

LWC Base Components enforce CRUD, FLS, and Sharing

  • lightning-record-form
  • lightning-record-edit-form
  • Lightning-record-view-form

LDS Wire adapters and functions enforce CRUD, FLS, and Sharing If calling Apex → apply the techniques just seen!

Enable Lightning web security in your Org.

  • From Setup, in the Quick Find box, enter Session, and then select Session Settings.
  • On the Session Settings page, select Use Lightning Web Security for Lightning web components and save.
  • Clear your browser cache after enabling or disabling Lightning Web Security to ensure the correct files are loaded in the browser. If you suspect that the correct security architecture is not in effect.

Load Assets Correctly

To import a third-party JavaScript or CSS library, use the platformResourceLoader module.

  • Download the JavaScript or CSS files from the third-party library’s site.
  • Upload the library to your Salesforce organization as a static resource, which is a Lightning security requirement.
  • In a component’s JavaScript file:
  • Import the static resource.

import myResourceName from ‘@salesforce/resourceUrl/myResourceName’;

  • Import methods from

import { loadStyle, loadScript } from ‘lightning/platformResourceLoader’;
Using the Lightning Platform resource loader guarantees your scripts always load in the correct order, are not duplicated, and load only when all dependencies have already loaded.
If the Lightning Platform resource loader is not used, it is possible that you or your customers may encounter page-breaking bugs as a result of a duplicated or improperly loaded script.

Visualforce page security

When does the Platform stop respecting FLS?
When you assign from a sObject to a primitive!

Apex: 

Random_Sensitive_Object_1__c r;
wRandom_Sensitive_Object_1 wR;
wR.Sensitive_Number = r.Sensitive_Number__c;

Visualforce:





We showed you how to respect FLS read permissions in Apex. Which one of the following would allow you to respect the FLS read permission in Visualforce?
Solution: 

  • Rendered=”{!$ObjectType.CustomObject__c.fields.CustomField__c.isAccessible}”
  • Rendered=”{!$ObjectType.CustomObject__c.CustomField__c.isAccessible()}”
  • Rendered=”{!$ObjectType.CustomObject__c.fields.CustomField__c.Accessible}”
  • Rendered=”{!$ObjectType.CustomObject__c.CustomField__c}”

Queueable Apex Class with Examples in Salesforce

1. What is Queueable Apex?

Queueable is one of the four Asynchronous Apex Methods used by a Salesforce Consultant in USA for submiting jobs for Async Processing it’s Similar to future Methods.

2. Future vs Queueable

–> Future Support only Primitive Data Types vs Queueable Support Primitive and non-Primitive Data Types.
–> We can’t monitor the jobs in Future vs Queueable monitor job depends on job Id.
–> We can’t call one future to another Future or batch apex. In the Queueable we can call one Queueable to another.
–> Future method does not return job id vs queueable returns Job id.
–> In the Future method You need to specify annotation to identify the Future method in Queueable you do not need to specify any specific annotation for identification.

3. Limitation of Queueable

  1. In the Queueable we can only one job can schedule at a time.
  2. Queueable can’t handle millions of Records at one Job.

4. Benifits of Queueable

1. Queueable support non-Primitive data types like Sobject Ex- Account, Contact, Or Custom Object as well.
2. If we want to chain one job to another job at that time, we can use Queueable.
3. If we want a job id, we will get using queueable, and using a job Id you can easily track the job.

5. Syntax Queueable

Implementation queueable Interface-
public class SampleClass implements Queueable {
public void execute (QueueableContext Qx){
// Here we Writing Code
}
}
queueable Interface:-  queueable Interface is the enhanced way of running asynchronous apex code
comparing to future async.

6. Steps Implementation

Following the below example, we are creating an Account record and also, we tracking jobs
Basically, two ways to track job Id: –

  1. UI Level
  2. SOQL Level

Below the Example we are creating a class QueueableDemo implements Queueable Interface
public class QueueableDemo implements Queueable{
public void execute(QueueableContext Qx){
system.debug(‘Here The execute method of QueueableDemo class’);
Account account = new Account();
account.Name = ‘Test Account’;
insert account;
system.debug(‘Account record inserted Here—->’+account.Name);
}
}

6.1 Tracking jobs Id from Apex jobs steps

Click on the Gear Setting Button select Set-Up-> Click the quick find box and Search Apex Jobs ->
Here you will get a list of job IDs and with help of a particular job Id you can easily track the job
Queueable

6.2 Tracking Job Id Help Of SOQL

Click below Query Editor tab -> Enter Here Soql -> Click to Execute
You will get all details here, as You Enter in the query
Query Example-
SELECT Id, Status, JobItemsProcessed, NumberOfErrors FROM AsyncApexJob where Id =                                ‘7075g00005dtaQg’.–>ExQueueable

Chaining Job in Queueable

Chaining a job is kind of chaining the job from one to another. Basically, chaining a job means running job after
Some other processing is completed first by another job.
In the below example, we changing jobs and also show the logs Similarly here three queueable class
QueueableDemo, QueueableDemoFirst, and QueueableDemoSecond are implemented by Queueable.

1. QueueableDemo

public class QueueableDemo implements Queueable{
public void execute(QueueableContext Qx){
system.debug(‘Here The execute method of QueueableDemo class’);
Account account = new Account();
account.Name = ‘Test Account’;
insert account;
system.debug(‘Account record inserted Here—->’+account.Name);
Id jobId = system.enqueueJob(new QueueableDemoFirst());
system.debug(‘QueueableDemoFirst job id is—->’+jobId);
}
}
Execute the below code in an anonymous window–>
Id jobId = system.enqueueJob(new QueueableDemo());
system.debug(‘QueueableDemo job id is–>’+jobId);

2. QueueableDemoFirst

public class QueueableDemoFirst implements Queueable{
public void execute(QueueableContext Qx){
system.debug(‘Here The execute method of QueueableDemoFirst class’);
Contact contact = new Contact();
contact.LastName = ‘Test Contact’;
insert contact;
system.debug(‘Contact Record Inserted Here —->’+contact.LastName);
Id jobId = system.enqueueJob(new QueueableDemoSecond());
system.debug(‘QueueableDemoSecond job id is—->’+jobId);
}
}

3. QueueableDemoSecond

public class QueueableDemoSecond implements Queueable{
public void execute(QueueableContext Qx){
system.debug(‘Here The execute method of QueueableDemoSecond class’);
StudentDetail__c studentDetails = new StudentDetail__c();
studentDetails.StudentAddress__c = ‘Abc Street’;
insert studentDetails;
system.debug(‘StudentDetail Record Inserted Here—->’+     studentDetails.StudentAddress__c);
}
}
Queueable
Queueable
Queueable

Conclusion:- Queueable apex is the Asynchronously running in the background. All job is going to the queueForm and Jobs are running when the system resource is available. Also, we can monitor the job help of job id.