Speed up CRM Analytics Recipe deployment 10X with help of a small Python script

Jan Placht
Capgemini Salesforce Architects
3 min readApr 5, 2024

Deploying CRM Analytics using Salesforce CLI presents a significant advancement over using Change Sets, aligning well with Salesforce project structures and version control practices, facilitating consistency across developer experiences and streamlining processes. However, a crucial limitation arises.

The Challenge: Automation of Analytics Integration and Security Profiles Updates

While components like dashboards, datasets, and recipes can seamlessly move between Salesforce Orgs, automating changes to Analytics Integration and Security Profiles proves intricate and ill-advised. This results in laborious tasks of identifying added or removed fields, adjusting profiles, and maintaining oversight. Operational guidelines can alleviate this, yet perfection remains elusive, often leading to error messages and deployment issues.

Addressing the Issue with Code Solutions

Rather than introducing more guidelines, a code-based approach offers a promising alternative. Consider recipes as JSON files describing each node, whether it involves loading operations, filters, or transformations. Key identifiers within the JSON reveal necessary fields for successful recipe execution.

CRM Analytics Recipe JSON
CRM Analytics Recipe JSON

One can easily spot that certain parts of the json (starting with “LOAD_” and being of type “connectedDataset”) clearly state what fields are used in this particular recipe node and therefore represent input data required for a successful run.

Drawing parallels to tools like Alembic for Python and databases, which track database schema changes, a similar concept can be applied to CRM Analytics recipes. Introducing the “Salesforce CRM Analytics Recipe Field Comparator” script, available under the MIT license on GitHub, provides a solution.

The script I’ve created to do the same for CRM Analytics recipes is called “Salesforce CRM Analytics Recipe Field Comparator” and was released under MIT on Github: https://github.com/jplacht/crma-recipe-revisions

Code and CLI options
Tool Python Code and CLI Options

Functionality Overview

  1. Analysis of CRM Analytics Recipes: The script examines the folder containing CRM Analytics recipes fetched via Salesforce CLI, identifying objects and their associated fields across all recipes.
  2. Revision Creation: It generates a revision detailing these objects and fields.
  3. Comparison on Deployment: When redeploying, the script compares the updated recipe status with the previous revision, highlighting additions or removals. This directs users to specific changes required, eliminating the need for manual comparisons or exhaustive documentation reviews.

An example revision file looks like this, spot how easy it is now to identify changes you need to do on your Integration and Security profiles:

{
"revision": "05e3767d-eb55-4375-8913-1734382c9d59",
"previous": "02a03999-9461-42ec-ad78-b520ab0ca3b0",
"created": "2024-03-27T11:57:40.996602",
"comparison": [
{
"name": "CustomObject_Test__c",
"additions": ["LastModifiedDate"],
"removals": ["CreatedDate"]
}
],
"current_fields": {
"CustomObject_Test__c": [
"Id",
"LastModifiedDate"
]
}
}

Key Advantages

1. Time Savings: This script, developed in just two hours, dramatically reduces deployment team hours by providing clear insights into necessary changes, bypassing manual Org comparisons.
2. Automation Potential: Small scripts like this exemplify the power of automation in handling repetitive tasks, leveraging clear data structures for computational efficiency.
3. Focus on Analytics Enhancement: By simplifying deployment processes, CRM Analytics projects can prioritize extending user capabilities with data and visualization enhancements, rather than routine maintenance.

Conclusion and Future Prospects

Initial feedback on the “Salesforce CRM Analytics Recipe Field Comparator” has been overwhelmingly positive, showcasing its potential for further development. While CLI commands offer initial functionality, collaboration and extension remain open for enhancing the tool’s capabilities.

Users are encouraged to engage, provide feedback, and contribute to its evolution.

Let’s continue exploring and enhancing analytical capabilities!

--

--

Jan Placht
Capgemini Salesforce Architects

Cloud Lead Analytics | Salesforce Applications Consultant @ Capgemini