From 663af8e9a61bd782582d4f574f82e5f244be2b92 Mon Sep 17 00:00:00 2001 From: Maciej Ptak <0ptaq0@gmail.com> Date: Sun, 27 Sep 2026 14:56:07 +0200 Subject: [PATCH 1/6] ci: deploy package with deps from sfdx-project --- .github/workflows/ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9771bbc..1502ee6 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,10 +9,12 @@ on: jobs: salesforce-ci: - uses: beyond-the-cloud-dev/cicd-template/.github/workflows/salesforce-ci.yml@main + uses: beyond-the-cloud-dev/cicd-template/.github/workflows/salesforce-ci.yml@feat/deps-from-sfdx-project with: - # package/ needs SOQL Lib and DML Lib installed; force-app/ vendors both - source-dirs: 'force-app examples' + template-ref: feat/deps-from-sfdx-project + # SOQL Lib and DML Lib come from the dependencies in sfdx-project.json + deploy-dependencies: true + source-dirs: 'package examples' node-version: '22' sf-cli-version: 'latest' scratch-org-duration: 1 From 3b2fe650800c77c52aa313a4bcdf5ec6fe4c8a42 Mon Sep 17 00:00:00 2001 From: Maciej Ptak <0ptaq0@gmail.com> Date: Sun, 27 Sep 2026 14:56:08 +0200 Subject: [PATCH 2/6] docs: state SOQL and DML dependencies --- README.md | 113 +++++++++++++++++++++++++++------------- website/installation.md | 27 ++++++++-- 2 files changed, 100 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 333d3c2..99bc52a 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,16 @@ Trigger Lib is part of [Apex Fluently](https://apexfluently.beyondthecloud.dev/) **Trigger** ```apex -trigger AccountTrigger on Account(before insert, after insert, before update, after update, before delete, after delete, after undelete) { - TriggerOrchestrator.run(new AccountTriggerOrchestrator()); +trigger AccountTrigger on Account( + before insert, + after insert, + before update, + after update, + before delete, + after delete, + after undelete +) { + TriggerOrchestrator.run(new AccountTriggerOrchestrator()); } ``` @@ -34,13 +42,16 @@ trigger AccountTrigger on Account(before insert, after insert, before update, af ```apex public with sharing class AccountTriggerOrchestrator implements TriggerOrchestrator.BeforeInsert, TriggerOrchestrator.AfterInsert { - public List beforeInsertHandlers() { - return new List{ new AccountRatingPopulator(), new AccountCustomerDataValidator() }; - } - - public List afterInsertHandlers() { - return new List{ new AccountWelcomeTaskWriter() }; - } + public List beforeInsertHandlers() { + return new List{ + new AccountRatingPopulator(), + new AccountCustomerDataValidator() + }; + } + + public List afterInsertHandlers() { + return new List{ new AccountWelcomeTaskWriter() }; + } } ``` @@ -48,13 +59,19 @@ public with sharing class AccountTriggerOrchestrator implements TriggerOrchestra ```apex public with sharing class AccountRatingPopulator implements BeforeInsert.Populator { - public Boolean populateOnBeforeInsertWhen(TriggerTypes.InsertRecord record) { - return record.isBlank(Account.Rating) && record.isNotNull(Account.AnnualRevenue); - } - - public void populateOnBeforeInsert(TriggerTypes.InsertRecord record) { - record.put(Account.Rating, record.greaterThanOrEqualTo(Account.AnnualRevenue, 5000000) ? 'Hot' : 'Warm'); - } + public Boolean populateOnBeforeInsertWhen(TriggerTypes.InsertRecord record) { + return record.isBlank(Account.Rating) && + record.isNotNull(Account.AnnualRevenue); + } + + public void populateOnBeforeInsert(TriggerTypes.InsertRecord record) { + record.put( + Account.Rating, + record.greaterThanOrEqualTo(Account.AnnualRevenue, 5000000) + ? 'Hot' + : 'Warm' + ); + } } ``` @@ -62,13 +79,16 @@ public with sharing class AccountRatingPopulator implements BeforeInsert.Populat ```apex public with sharing class AccountCustomerDataValidator implements BeforeInsert.Validator { - public Boolean addErrorOnBeforeInsertWhen(TriggerTypes.InsertRecord record) { - return record.startsWith(Account.Type, 'Customer') && record.isBlank(Account.Industry); - } - - public void addErrorOnBeforeInsert(TriggerTypes.RejectableInsertRecord record) { - record.addError(Account.Industry, 'A customer account requires Industry.'); - } + public Boolean addErrorOnBeforeInsertWhen(TriggerTypes.InsertRecord record) { + return record.startsWith(Account.Type, 'Customer') && + record.isBlank(Account.Industry); + } + + public void addErrorOnBeforeInsert( + TriggerTypes.RejectableInsertRecord record + ) { + record.addError(Account.Industry, 'A customer account requires Industry.'); + } } ``` @@ -76,22 +96,43 @@ public with sharing class AccountCustomerDataValidator implements BeforeInsert.V ```apex public with sharing class AccountWelcomeTaskWriter implements AfterInsert.Writer, AfterInsert.ParentQuery, AfterInsert.ContinueOnError { - public Map queryParentsOnAfterInsert() { - return new Map{ Account.OwnerId => TriggerTypes.ParentFields.with(User.Name) }; - } + public Map queryParentsOnAfterInsert() { + return new Map{ + Account.OwnerId => TriggerTypes.ParentFields.with(User.Name) + }; + } + + public Boolean writeOnAfterInsertWhen(TriggerTypes.InsertRecord record) { + return record.startsWith(Account.Type, 'Customer'); + } + + public void writeOnAfterInsert( + TriggerTypes.InsertRecord record, + TriggerTypes.UnitOfWork unitOfWork + ) { + Account newAccount = (Account) record.getNewSObject(); + User owner = (User) record.getNewParent(Account.OwnerId); + + unitOfWork.toInsert( + new Task( + WhatId = record.getId(), + OwnerId = newAccount.OwnerId, + Subject = 'Onboarding call - ' + newAccount.Name, + Description = 'Assigned to ' + owner?.Name + ) + ); + } +} +``` - public Boolean writeOnAfterInsertWhen(TriggerTypes.InsertRecord record) { - return record.startsWith(Account.Type, 'Customer'); - } +## Dependencies - public void writeOnAfterInsert(TriggerTypes.InsertRecord record, TriggerTypes.UnitOfWork unitOfWork) { - Account newAccount = (Account) record.getNewSObject(); - User owner = (User) record.getNewParent(Account.OwnerId); +Trigger Lib is built on two other Apex Fluently libs, so they have to be in the org too: - unitOfWork.toInsert(new Task(WhatId = record.getId(), OwnerId = newAccount.OwnerId, Subject = 'Onboarding call - ' + newAccount.Name, Description = 'Assigned to ' + owner?.Name)); - } -} -``` +- [SOQL Lib](https://soql.beyondthecloud.dev) 6.12.0 +- [DML Lib](https://dml.beyondthecloud.dev) 4.0.0 + +Installing the packages? Install SOQL Lib and DML Lib first. The [installation guide](https://trigger.beyondthecloud.dev/installation) has the links in the right order. The button below deploys both together with Trigger Lib. ## Deploy to Salesforce diff --git a/website/installation.md b/website/installation.md index abcefad..9643873 100644 --- a/website/installation.md +++ b/website/installation.md @@ -4,6 +4,15 @@ description: Install Trigger Lib in a Salesforce org - deploy via button, or cop # Installation +::: info Dependencies +Trigger Lib is built on two other Apex Fluently libs, so they have to be in the org too: + +- [SOQL Lib](https://soql.beyondthecloud.dev) 6.12.0 +- [DML Lib](https://dml.beyondthecloud.dev) 4.0.0 + +Every install option below says how to get them. +::: +