Salesforce DX

Automate Scratch Org Setup with PowerShell

I really like working with Salesforce DX and scratch orgs. However, in larger projects it can be time consuming to create a scratch org, install dependencies, push code, assign permission sets and setup test data. After doing this manually for a while I created a PowerShell script to automate the process. In a large project the script can still take some time to run but at least I can let it run while I do something else.

Test Salesforce REST API with Postman

Postman is my favorite tool for testing REST APIs. Workbench is great for ad-hoc testing but I like Postman better because I can create a suite of repeatable, scriptable tests. You can download and install Postman from getpostman.com. When you run it you should see the main screen. Postman main screen Prerequisites In this post we will test the REST API we created in the last few posts. To follow along with this post you can clone the GitHub repo and push the code to a scratch org or start at the beginning of the series if you would like to follow along with building the API.

Unit Test a Salesforce REST API

This post is a continuation of the previous two posts where we created a Salesforce DX REST API project and then coded HTTP methods to perform CRUD operations. The full project is on GitHub. In this post we will cover some general unit testing concepts and specifically how to unit test HTTP methods in Apex. Arrange, Act, Assert There is a common pattern in unit tests called Arrange, Act, Assert. It states that each unit test does these three things.

Create a REST API with SFDX, Part 2

In part 1 we setup our scratch org and created our custom object. In this post we will build out the API. First, create a new class in Visual Studio Code called HouseService. From the command palette in VS Code select SFDX: Create Apex Class and enter the name of the class. A few things to note about the class definition: @RestResource identifies our class as a REST endpoint.

Create a REST API with SFDX, Part 1

In the next couple of posts we will create a REST API with Salesforce DX. First we’ll create a custom object and then expose that object through a REST API. When it’s complete we will have an API for a custom object that is similar to the built in Salesforce REST API for sObjects. You can download the code for this project from GitHub. In this first post we’re going to take care of the preliminaries: