Blog Posts

Blog Posts

Step by Step Guide to OAuth External Credential with Client Credentials with Client Secret Flow

Here is another guide in the series of guides that we have come up with on how to use different authentication protocols in External Credentials in Salesforce to authenticate with external systems.

(External credentials enable the safe and secure storage of authentication details for external systems. Configured through the declarative, point-and-click features of Salesforce, they significantly reduce the need for custom code that would otherwise be necessary to establish connections and authenticate with external systems.)

In this guide we will learn how to configure & use External Credential with “Client Credentials with Client Secret” to integrate one Salesforce Org with another Salesforce Org. But before we dive into this guide, here is an overview of all the different authentication protocols that external credentials support.

Salesforce External Credential Authentication Protocols – Lay of the Land

External Credentials in Salesforce support different authentication protocols to suit diverse requirements. The diagram below shows the lay of the land regarding the various authentication protocols available within external credentials.

In this post, we will learn how to use the OAuth External Credential with Client Credentials with Client Secret (highlighted by the red arrow in the image below).

Overview of External Credential Authentication Protocols in Salesforce

Begin with the End in Mind

Here is what we will be configuring in this guide: Our end goal is to create an Account record in one Salesforce Org from another Salesforce Org using Salesforce API. And for authentication from source Salesforce org to target Salesforce org, we will be using the OAuth External Credential with Client Credentials with Client Secret.

Create Account Record in Salesforce through API

OAuth External Credential with Browser Flow Configuration Components

Here is a visual representation of all the components that need to be configured for the Client Credentials with Client Secret Flow. While this may seem like a lot (and it is), don’t worry. I have you covered with an exhaustive, step-by-step guide complete with screenshots, so that you don’t get lost.

OAuth External Credential with Client Credentials with Client Secret Configuration Components

And here is a visual representation of the flow between source Salesforce org and target Salesforce org.

OAuth External Credential with Client Credentials with Client Secret Flow

Finally, here is the overview of steps we are covering in this guide. Step by step, with screenshots.

  1. Create Connected App in Target Org
  2. Create External Credential
  3. Create Named Credential
  4. Create/Update Permission Set
  5. Create Screen Flow with HTTP Callout
  6. Test the Flow

Not an “All Access” Pass Member Yet?

Get Download Access to this & 150+ More Step-by-Step Guides with “All Access” Pass. A simple and single plan to access our entire library of courses, guides, workshops & masterclasses on Salesforce.

References & Useful URLs

Step By Step Guide On Getting Started With Macros in Salesforce

Macros in Salesforce

Macros can be a huge productivity booster for your end users and can provide a great user experience in using Salesforce. If you have used macros in Microsoft Excel, you already know what it is. Macros in Salesforce also works in the same manner. It helps users perform common, repetitive tasks in a single click. For example, with the click of a button, you can  

  • send an email to a lead or contact
  • update the status of one or more records
  • create a task for self and setup due date using relative dates
  • create an event (meeting) with Lead or Contact

You create a macro by specifying the instructions for actions that the macro performs. You tell the macro each step that it performs. New Macro Builder in Lightning Experience is an intuitive tool to build your Macros easily in no time. Supported actions are highlighted in blue on mouse hover so you know what actions you can take using Macro. Just follow the exact steps while configuring Macro instructions that you would otherwise perform manually.

There are two kinds of Macros in Salesforce

  • Irreversible Macros
  • Bulk Macros

Irreversible Macros

These refer to the actions once performed can’t be undone. e.g. If a Macro has an instruction to send an email then once that Macro is run successfully the send email action cannot be undone.

Bulk Macros

As the name suggests you can run Macro on multiple records at the same time so you can save even more time from your routine tasks an be more productive.

Macros Folders

You can also organize Macros in folders. Create separate folders for different divisions and then share the folder with a user or group of users in that division. Also, you can set the folder access level and delegate some of your responsibility to your users.

So let’s get started and within the next 30 minutes or so you will be in a better position to create your own Macro according to your business needs. Here is what we will be covering in this guide:

  1. Preparation Steps
  2. Add Macros Utility to Console App
  3. Enable Macros Folders
  4. Create & Share Macros Folder
  5. Create a Macro
  6. Run a Macro as End User

(In this guide we will be configuring Macros in an app with Console Navigation. If you are not familiar with Console navigation in Salesforce, here is another step-by-step guide on getting started with Salesforce Console. Macros + Salesforce Console = User’s Productivity on Steroids)

NOTE: Certain sections of the guide will appear as locked in the free preview. You can download the unlocked version of the guide in PDF format by subscribing to our “All Access” Pass through the link below.

Not an “All Access” Pass Member Yet?

Get Download Access to this & 150+ More Step-by-Step Guides with “All Access” Pass. A simple and single plan to access our entire library of courses, guides, workshops & masterclasses on Salesforce.

Here is a short video (approx 5 minutes) to bring macros to life for you

References & Useful URLs

  1. Salesforce help article – Set Up and Use Macros
  2. Blog Post – Step By Step Guide on Getting Started with Salesforce Console
  3. Blog Post – How To Set Up & Use Quick Text in Salesforce
  4. Blog Post – Step By Step Guide To Using Email Templates in Salesforce

How To Create & Send Custom Desktop/Mobile Notification in Salesforce

A Step-by-Step Guide to Notify Users When Important Events Occur

Custom Desktop/Mobile Notification in Salesforce

Empower your users to stay on top of important events with Salesforce Custom Notifications, a powerful feature introduced in the Summer ’19 release. Unleash the ability to send tailored push notifications on mobile devices or desktop alerts, ensuring your users are always in the loop.

Salesforce Custom Notifications Setup

Setting up Custom Notifications is a breeze and follows a straightforward, declarative process. Begin by creating a custom notification type. Enable notifications for both Lightning Experience and the Salesforce Mobile App. And then create a Flow with ‘Send Custom Notification’ action, that was introduced in Winter ’20 release.

Better Alternative to Email Alerts

Custom Notifications emerge as a superior alternative to traditional email alerts. Consider scenarios like creating a Case for an Account – sending a custom notification to the Account owner with Case details proves more effective than an email. Why? Clicking on the notification allows direct access to the specific record, minimizing app-switching and enhancing user experience.

Enhance user engagement and streamline communication within your Salesforce environment by implementing Custom Notifications. Invest 15-20 minutes in this guide to unlock the full potential of this feature. Your users will appreciate the real-time updates, and you’ll witness a seamless, efficient workflow in your Salesforce org. Ready to revolutionize your notification strategy? Try it out today!

Here’s what this guide covers:

  1. Enable Notifications
  2. Create a Custom Notification Type
  3. Create a Flow to Send Notification
  4. Test Custom Notification

NOTE: Certain sections of the guide will appear as locked in the free preview. You can download the unlocked version of the guide in PDF format by subscribing to our “All Access” Pass through the link below.

Not an “All Access” Pass Member Yet?

Get Download Access to this & 150+ More Step-by-Step Guides with “All Access” Pass. A simple and single plan to access our entire library of courses, guides, workshops & masterclasses on Salesforce.

References & Useful URLs

How to Lock Records in Salesforce?

In Salesforce, sometimes you would want to lock records in Salesforce so that they can no longer be edited or deleted. When a record has reached the end of its lifecycle, nobody should be allowed to modify the record any longer.

For example, once an opportunity record is closed (closed won or closed lost), it just needs to live in the system without being touched. Same can be for “Cases” or records sitting in your custom objects. Or maybe once a record has been interfaced to a backend system, you would want to lock the record so that it can no longer be modified in Salesforce.

Error Message when a user is trying to edit a locked record in Salesforce

How Do You Lock Records in Salesforce?

Traditionally Salesforce professionals have used different options to meet this requirement & each of these options have its own pros and cons. They include:

  1. Using Record Type & Page Layouts: Create two different record types say “Open” & “Locked” and change the record type of the record using workflow field update or trigger. And then create a separate page layout for the “Locked” record type with all fields marked as ‘Read-Only’. Remove the ‘Edit’ and ‘Delete’ buttons from the page layout. However, this is not an option if you are using record types for some other purpose and do not want to change it just to meet this requirement. Also, note that using this to lock records is not a fool-proof solution as users will still be able to edit the record from the list view.
  2. Using Record Ownership: Automatically change the owner of the record using record-triggered flow or apex trigger and make sure that the OWD (Organization Wide Default) and sharing rules are setup correctly to prevent updates or deletes. Again, this may not be an option for you if you can’t change the record owners as it may have other impacts (e.g. reporting).
  3. Trigger: Write a trigger (before update, before delete) on the object and based on the desired condition raise an error. Triggers have two issues. One it is a custom development and second, the user will receive an error after they have made the changes and trying to save the record. Not a good option from the user’s experience point of view.
  4. Validation Rule: Write validation rule using ISCHANGED function. Here you will need to know for what all columns will you need to use the ISCHANGED function, and users will receive error once they have made the changes and trying to save record.
  5. Custom VF Page: Create custom Visualforce page and dynamically show/hide the ‘Edit’, ‘Delete’ buttons.

In this guide, we will explore a much better option, where we will actually “lock” the record using one of Salesforce’s out of the box declarative feature. Once locked the end users will see an error when they try to edit the record. Let’s take a look.

Not an “All Access” Pass Member Yet?

Get Download Access to this & 150+ More Step-by-Step Guides with “All Access” Pass. A simple and single plan to access our entire library of courses, guides, workshops & masterclasses on Salesforce.

Git and Salesforce: A Getting Started Guide for Development

Many developers find it challenging to use Git with Salesforce. Even though about 99% open-source projects use some kind of version control like Git, it’s still hard to blend it smoothly into Salesforce projects. This can lead to lost work, confusion over different code versions, and trouble working together.

This guide offers a step-by-step approach to seamlessly integrating Git with Salesforce, ensuring your development process is smooth, efficient, and error-free.

Understanding Git Basics

Git is a distributed version control system designed to help developers track changes in their code over time. It allows multiple developers to collaborate seamlessly on a project by providing a central repository where all changes are stored.

4 Key Git Concepts

In Salesforce development, Git introduces critical concepts such as repositories, branches, commits, and pull requests to enhance version control and collaboration.

  1. A repository is where the source code and project files are stored. It serves as the single source of truth for the development team.
  2. A branch is a pointer to a specific commit in the repository and represents an independent line of development.
  3. Commits represent a set of changes made to the code and include a unique identifier. It acts as a snapshot of the code at a specific point in time, enabling developers to track and manage the evolution of the codebase.
  4. Pull requests provide a platform for collaboration and team ownership in the development process. When developers complete their work on a feature branch, they can create a pull request to propose their changes for merging into the main codebase.

9 Best Practices for Version Control in Salesforce

Version control is crucial for Salesforce development as it helps track changes, collaborate efficiently, and maintain code integrity. Here are the best practices for version control in Salesforce:

1. Choose the Right Version Control System

  • Git is King: Given its widespread adoption and robust features, Git is often the preferred choice. It’s crucial to select a version control system that integrates well with Salesforce and meets the team’s collaboration needs.

2. Branching Strategy

In Salesforce projects, implementing effective strategies for branching and merging is crucial for maintaining code stability and facilitating collaboration among developers. Here are some strategies to consider in your branching strategy:

  1. Implement a Branching Model: Use a branching strategy like GitFlow or Feature Branching to manage different development streams, new features, and bug fixes.
  2. Isolate Development: Keep feature development and bug fixes separate from the main branch to avoid conflicts and ensure stability.
  3. Feature Branching: Create separate branches for each new feature or development task. This allows developers to work independently without impacting the stability of the main branch. Once the feature is complete, it can be merged into the main branch.
  4. Release Branching: Create a release branch before deploying changes to production. This branch acts as a controlled environment for testing and finalizing features. Once the release branch is stable, it can be merged into the main branch for deployment.
  5. Continuous Integration: Implement a continuous integration process to merge changes from different developers into the main branch frequently. This ensures that conflicts are identified and resolved quickly, promoting seamless collaboration.

3. Consistent Commit Practices

  • Frequent Commits: Regularly commit changes to track progress and avoid massive, hard-to-manage updates.
  • Descriptive Commit Messages: Each commit should have a clear, concise message that explains the changes and the reason behind them.

4. Automate Deployments

  • Continuous Integration (CI): Implement CI to automate the testing and deployment of Salesforce metadata. Tools like Jenkins, Bamboo, or Salesforce DX can be used.
  • Validate Before Deploying: Always validate your changes in a test environment or scratch org before merging into the main branch.

5. Handle Conflicts Promptly

  • Regular Merges: Frequently merge changes from the main branch into feature branches to minimize conflicts.
  • Conflict Resolution: When conflicts arise, resolve them promptly and carefully to maintain code integrity.

6. Track and Audit Changes

  • Use History Wisely: Leverage the version history to understand changes, roll back when necessary, and audit modifications for compliance and debugging.

7. Backup and Security

  • Regular Backups: Ensure your version control repository is backed up regularly to prevent data loss.
  • Access Control: Manage access to the repository, ensuring that only authorized personnel can make changes to critical branches.

8. Training and Documentation

  • Educate Your Team: Ensure that all team members are trained in using version control systems and understand the team’s branching and commit strategies.
  • Document Your Processes: Maintain clear documentation for your version control processes, standards, and branching model.

9. Review and Refine

  • Code Reviews: Implement peer review processes for commits to improve code quality and share knowledge within the team.
  • Iterate Your Strategies: Regularly review and update your version control strategies to adapt to changing project needs and team dynamics.

Setting up Git for Salesforce Development

Setting up Git for Salesforce development is essential for effective version control and seamless collaboration within development teams. With version control, you can track changes, revert to previous versions if necessary, and maintain a centralized repository for your codebase.

To integrate Git with Salesforce DX, follow these steps:

1. Install Git: Begin by installing Git on your local machine. Visit the Git website and download the appropriate version for your operating system. It’s available for Windows, Mac, and Linux.

2. Set up Salesforce DX: Salesforce DX is a set of tools and features that enhance development on the Salesforce platform. Install Salesforce CLI, which includes the necessary commands to interact with Salesforce DX. Visit the Salesforce CLI installation page.

3. Initialize Git: Open the command line interface and navigate to your project directory. Use the the following command to initialize Git within your project folder.

git init

4. Connect to a remote repository: If you already have a remote repository set up, use the following command to connect your local repository to the remote one. If not, create a new repository on a hosting platform like GitHub or Bitbucket and then run the following command

git remote add origin <remote_repository_URL>

5. Create a Salesforce DX project: Use the Salesforce CLI to create a new project in your desired directory. This project will serve as the local workspace for your Salesforce development. In your prompt, run the following:

sf project generate -n my-salesforce-project

6. Work with scratch orgs: Salesforce DX uses scratch orgs, which are temporary Salesforce environments for development and testing. Use the Salesforce CLI to create and manage scratch orgs. Develop and test your changes in these orgs before pushing them to the main codebase.

sf org create scratch -edition developer -alias my-scratch-org

7. Create Branches: Create separate branches for different features or bug fixes using the following command command. This allows for isolated development and enables team ownership of specific features.

git branch feature-branch-name

8. Switch to the branch: Switch to the newly created branch using the following command. This will ensure that any changes you are making to the code will be saved in the new branch.

git checkout - b feature-branch-name

9. Make changes in scratch org: Use the Salesforce CLI and your preferred development tools, such as Visual Studio Code, to make necessary changes to the scratch org.

10. Pull changes: If the changes have been made directly in the Salesforce Org, and once you are satisfied with the changes made, pull these changes from the org as metadata files to store it in source control.

sf project retrieve start

11. Push changes to the Git repository: use Git commands to add and commit the changes locally. Then, push these changes to the corresponding branch in the Git repository.

git add [file-name or .]
git commit -m "Description of the changes"
git push origin feature/my-feature-branch

12. Merge changes: To ensure collaboration with other developers, regularly pull changes from the principal or developer branches using Git commands. Merge these changes into your branch to incorporate the latest updates.

git checkout main
git pull origin main
git checkout feature/my-feature-branch
git merge main

Handling Conflicts and Merges

Resolving conflicts and effectively merging changes is essential for maintaining code stability and ensuring a smooth development process. To handle conflicts in Salesforce metadata, developers can follow these steps:

  1. Identify the conflicting components: Use the Git command line interface or a Git GUI tool to identify the components with conflicting changes.
  2. Understand the changes: Review the conflicting changes made by different developers to understand the differences and determine the desired outcome.
  3. Make necessary adjustments: Modify the conflicting metadata components to resolve the conflict. This could involve reconciling differences, rewriting code, or collaborating with other developers to find a resolution.
  4. Test the changes: After resolving the conflict, it is crucial to test the merged components thoroughly to ensure code stability and functionality.
  5. Commit and push the changes: Once the conflicts are resolved and the code is stable, commit the changes to the respective branch and push them to the remote repository.

Final Thoughts

Using Git and Salesforce can significantly enhance the development process and improve collaboration within development teams. Git-based version control provides a centralized and organized system for managing code changes, ensuring a single source of truth for the development project.

With features like branches and pull requests, developers can work on separate features and easily merge them into the main codebase. This allows for seamless collaboration and a tighter feedback loop within the team.

If developers integrate third-party DevOps tools and automation, the development and deployment process can be streamlined and more efficient. Additionally, scratch orgs and clicks-based DevOps solutions enable developers to quickly and easily test and deploy changes in a production-like environment.

Scroll to Top
Introducing All Access Pass