A Salesforce Net Zero Cloud accelerator for automatic water footprint linking, built with Apex Enterprise Patterns (fflib)
One-click deployment to your Salesforce org
Note: Replace
YOUR_GITHUB_ORGwith your GitHub username or organization. Alternatively, use the Salesforce CLI deployment method below.
- Automatic Footprint Linking: On insert of StnryAssetWaterActvty records, finds or creates matching StnryAssetWaterFtprnt records
- Schema-Aware: Handles StartDate/StrtDt field variations across Net Zero Cloud orgs
- Unit of Work: All DML via fflib_SObjectUnitOfWork for bulkified, transactional operations
- Selector/Service Layering: Encapsulated SOQL in Selectors, business logic in Services
- fflib Integration: Trimmed fflib subset (UnitOfWork, Selector, Application) β no mocks
- Dependency Injection: Application.cls factory for UnitOfWork and Selector resolution
Before you begin, ensure you have the following:
- β Salesforce Net Zero Cloud licensed and configured
- β Git installed on your local machine
- β Salesforce CLI (latest version recommended)
- β Salesforce user with deployment permissions
- β Active Salesforce org (Sandbox or Developer Edition)
Choose your preferred deployment method:
Click the "Deploy to Salesforce" button above for instant deployment to your org. Ensure you replace YOUR_GITHUB_ORG in the deploy URL with your GitHub username or organization.
For environments where GitHub access is restricted:
- Download the pre-built deployment package:
- Direct download: Water-Footprint-Automation-Deploy.zip
- Or download from the GitHub Releases tab
- Navigate to Salesforce Workbench
- Login to your target org
- Go to Migration β Deploy
- Upload the zip file and deploy
Alternative Tools: You can also deploy using Salesforce Inspector or the Ant Migration Tool.
For developers who prefer command-line tools:
git clone https://github.com/YOUR_GITHUB_ORG/water-footprint-automation.git
cd water-footprint-automation# For sandbox/production orgs
sf org login web --alias MyOrg --instance-url https://test.salesforce.com
# For developer orgs
sf org login web --alias MyOrg# Deploy all components (Salesforce CLI v2)
sf project deploy start --source-dir force-app --target-org MyOrg
# Or using legacy sfdx command
sfdx project deploy start --source-dir force-app --target-org MyOrgNote: This accelerator is compatible with CI/CD tools like Gearset, Copado, and Flosum.
After deploying with any method above, complete these manual steps:
-
Verify Net Zero Cloud Objects
- Ensure StnryAssetWaterActvty, StnryAssetWaterFtprnt, and StnryAssetEnvrSrc exist in your org
- The trigger and service expect standard Net Zero Cloud schema
-
Assign Permissions
- Grant users access to the custom classes and trigger as needed
- Ensure profiles/permission sets include access to StnryAssetWaterActvty and StnryAssetWaterFtprnt
The StnryAssetWaterActvty trigger runs automatically on insert:
- Create StnryAssetWaterActvty records (via UI, API, or Data Loader)
- Trigger fires after insert and delegates to
StnryAssetWaterActvtyService.linkOrCreateFootprints() - Service finds or creates matching StnryAssetWaterFtprnt records and populates
StnryAssetWaterFtprntIdon activities - No manual steps required β footprint linking is fully automated
This accelerator contains the following metadata:
- 1 Trigger (
StnryAssetWaterActvtyTrigger) - 4 Custom Apex Classes (
StnryAssetWaterActvtyService,StnryAssetWaterFtprntSelector,StnryAssetWaterSchema,Application) - 4 Test Classes (
StnryAssetWaterActvtyServiceTest,StnryAssetWaterActvtyTriggerTest,StnryAssetWaterFtprntSelectorTest,StnryAssetWaterSchemaTest) - fflib Framework (trimmed subset: UnitOfWork, Selector, Application, QueryFactory, SObjects, etc.)
graph TB
A[StnryAssetWaterActvtyTrigger] --> B[StnryAssetWaterActvtyService]
B --> C[StnryAssetWaterFtprntSelector]
B --> D[fflib_SObjectUnitOfWork]
C --> E[StnryAssetWaterFtprnt]
B --> F[StnryAssetWaterSchema]
D --> G[StnryAssetWaterActvty]
D --> E
| Component | Description |
|---|---|
StnryAssetWaterActvtyTrigger |
After-insert trigger; delegates to Service for footprint linking |
StnryAssetWaterActvtyService |
Orchestrates find-or-create footprint logic; uses Selector and UnitOfWork |
StnryAssetWaterFtprntSelector |
Encapsulates SOQL for StnryAssetWaterFtprnt; selectByEnvrSrcIdsAndDateRange() |
StnryAssetWaterSchema |
Discovers date field API names (handles org schema variations) |
Application |
DI factory for UnitOfWork and Selector resolution |
We welcome contributions to improve Water Footprint Automation! See CONTRIBUTING.md for detailed guidelines. In short:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Salesforce coding standards
- Adhere to Apex Enterprise Patterns in
.cursor/rules/Apex Rules.mdc(Selector/Service layering, UnitOfWork) - Include comprehensive test coverage (>75%)
- Update documentation for new features
- Test thoroughly in multiple org types
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Found a bug or have a feature request? Please report it via GitHub Issues.
When reporting bugs, please include:
- Steps to reproduce the issue
- Expected vs. actual behavior
- Salesforce org version and edition
- Screenshots or error messages (if applicable)
- π Documentation: See REPOSITORY_SUMMARY.md for architecture details; scripts/README.md for CSV transform usage
- π¦ Dependencies: See DEPENDENCIES.md for dependency graph setup and npm packages
- π Issues: Report bugs via GitHub Issues
- π¬ Discussions: Join the conversation in GitHub Discussions
- π§ Contact: Reach out to the maintainers for enterprise support
This accelerator is open-source, not an official Salesforce product, and is community-supported. Salesforce does not provide official support for this accelerator. Use at your own risk and test thoroughly in a sandbox environment before deploying to production.
Made with β€οΈ for the Salesforce Community
β Star this repo if you find it helpful!