Follow and complete a Learn MOAR Spring ’23 trailmix for admins or developers by March 31, 2023, 11:59 p.m. PT to earn a special community badge and be automatically entered for a chance to win one of five $200 USD Salesforce Certification vouchers. Restrictions apply. Learn how to participate and review the Official Rules by visiting the Trailhead Quests page.
DevOps Center is Generally Available
If you didn’t hear, DevOps Center became Generally Available in December 2022. This is great news as DevOps Center simplifies the process of moving changes between environments, detecting modified metadata automatically, recording all the operations in a GitHub repo behind the scenes, and allowing stronger and easier collaboration between release managers, admins, and developers. New capabilities have been added for the GA release, including:
- The addition of more ways of managing environments, like the ability to swap a sandbox when it’s refreshed
- To prevent errors, an automatic verification of source tracking when connecting to development environments
- The redesign of the pipeline setup page, so that it’s easier to define environments and pipeline stages in a single view
- The ability to perform validate-only deployments
And there’s something special that I want to highlight: now you can activate DevOps Center in your scratch orgs. This is helpful if you’re an ISV partner who wants to build packages to extend DevOps Center functionality.
On top of all this, know that the Salesforce CLI will soon incorporate commands for managing DevOps Center in an automated way. Looking forward to it!
Updates to the Salesforce CLI
The Salesforce CLI has its own release notes and release schedule (they release weekly!). The Salesforce CLI release notes are divided into two sections: innovations for the
sf CLI and the
sfdx CLI. The
sf CLI was created to unify the CLIs from different Salesforce products and clouds without disrupting the regular
sfdx one. There are lots of innovations for both CLIs that were published in the Spring ’23 release. Let’s take a look at them:
CLIs alignment and plugin writing improvements
Some weeks ago, the Salesforce CLI team posted a blog talking about the key items on their roadmap for 2023. Some of these improvements are already available as part of the Spring ’23 release, such as:
- An improved typing experience and removal of taxonomy restrictions on the
- Alignment of some commands (
- Improvements to the Plugin Developer Experience
More metadata types are supported
A lot of new metadata types are supported by the
sfdx force:source:* and
sf deploy|retrieve metadata commands. For instance,
DigitalExperience are now supported, allowing for partial deploys of your LWR-based Experience Cloud configuration. Check the release notes for the complete list of new metadata types supported.
Running diagnostic tests with the new
A new command,
sfdx doctor or
sf doctor, adds the ability to quickly gather Salesforce CLI configuration data and run diagnostic tests. After running the command, you can share the generated report with Salesforce support, or add a flag so that a GitHub issue is created automatically on the corresponding Salesforce CLI or Salesforce CLI plugin repo.
Determining which plugin a command is in with the new
Now you can determine which plugin a command is in with the new
sfdx which or
sf which command. For example:
sf which "deploy metadata".
Replace strings on your metadata just for deployment
One of the coolest features is that now you can automatically replace snippets of your metadata source files with specific values, right before you deploy them. This string replacement is “ephemeral” because the changes aren’t written to your project, just to the deployed files. This can be used to write different URLs and secrets in
ConnectedApps, etc. when you’re deploying to different environments.
To configure string replacement, you add a
replacements property to your
sfdx-project.json as follows:
With this project configuration, every time that you deploy using the
sfdx force:source:deploy|push or
sf deploy|retrieve metadata commands, the replacement will take place on the deployed files. The replacement feature is very versatile, accepting different options:
- You can specify a single file with
filename, or a collection of files using the
**/classes/*.cls) in which the string should be replaced
- You can indicate a
stringToReplaceor a regular expression in the
- You can replace the string with the value of an environment variable (
replaceWithEnv), and with the contents of a file (
- You can add conditions for when to replace the string using
As an example, let’s take our Ready to Fly sample app, a travel approvals app that integrates Salesforce and Slack. In Ready to Fly, we implemented our own string replacement script to dynamically generate various metadata types. Let’s check the
NamedCredential metadata from the sample app that Ready to Fly uses to connect to a middleware Heroku app. Our
NamedCredential template was:
While before, we had to write and run our own script to perform the replacement:
Now, we can do something like this:
This means you can perform the replacement without having to write your own script, but also that your metadata templates can live in your project folder and remain unchanged after different deployments. Don’t wait any longer and get your hands on it now!
Wow, that was a lot! Bear in mind the Salesforce CLI team releases every week, so I recommend that you keep an eye on the Salesforce CLI release notes, so you can adopt new features that can save you time and resources early!
Learn MOAR this week
Our Product Managers and Developer Advocates are back to share the latest features and functionality. To help you develop faster, there’s a wealth of new content from Developer Relations covering their favorite new features. Be sure to check out Release Readiness Live on Friday, January 20th at 9:00 PST, and read all the latest Salesforce Developers blog posts for more developer-related innovations in the Spring ’23 release!
To learn even more, check out the Spring ’23 trailmix.
About the author
Alba Rivas works as a Principal Developer Advocate at Salesforce. She currently focuses on Lightning Web Components and Slack development. You can follow her on Twitter or Linkedin.