Before you start
Log in to the org as the admin user, then run Step 0 once to seed the walkthrough data. Every "Open …" button below deep-links into this specific scratch org. Every Apex block is copy-to-clipboard: paste it into Setup → Developer Console → Debug → Open Execute Anonymous Window, or save it to a .apex file and run sf apex run --file <file> --target-org SystemTrackerTest.
Seed the walkthrough dataAdmin
Creates the foundation this guide links to: an Aviation Program and Project, published System Templates (Door → Camera), seeded Systems & Equipment (a Door with a child Camera), a Control Gate, a Transition Event + Stakeholder, and an Inspection Request. The script is idempotent — safe to re-run.
// Run once. Idempotent. Also saved as seed_walkthrough.apex in this folder.
// sf apex run --file "System Tracker Build/System Testing Walkthrough/seed_walkthrough.apex" --target-org SystemTrackerTest
String IND = 'Aviation';
List<CitiriOS__Program__c> progs = [SELECT Id FROM CitiriOS__Program__c WHERE Name = 'RCT Walkthrough Program' LIMIT 1];
CitiriOS__Program__c prog = progs.isEmpty() ? new CitiriOS__Program__c(Name = 'RCT Walkthrough Program') : progs[0];
if (progs.isEmpty()) { insert prog; }
List<CitiriOS__Project__c> projs = [SELECT Id FROM CitiriOS__Project__c WHERE Name = 'RCT Walkthrough Project' LIMIT 1];
CitiriOS__Project__c proj = projs.isEmpty()
? new CitiriOS__Project__c(Name = 'RCT Walkthrough Project', CitiriOS__Program__c = prog.Id, CitiriOS__Industry__c = IND)
: projs[0];
if (projs.isEmpty()) { insert proj; }
System.debug('Project: ' + proj.Id);
// Full script (templates, equipment, gate, IR) lives in seed_walkthrough.apex.
The complete script is in seed_walkthrough.apex beside this file — run that for the full seed. The button above is a preview.
Confirm access & published templatesAdmin
The admin user already carries the Citiri_Admin permission set group, which includes COS_Commissioning_Manage and COS_Commissioning_Governance. Run the snippet below only if you are testing as a different user and need to grant commissioning access explicitly.
Set<String> want = new Set<String>{
'COS_Commissioning_Manage', 'COS_Commissioning_Governance',
'CitiriOS__COS_Commissioning_Manage', 'CitiriOS__COS_Commissioning_Governance'
};
Set<Id> have = new Set<Id>();
for (PermissionSetAssignment a : [SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId = :UserInfo.getUserId()]) {
have.add(a.PermissionSetId);
}
List<PermissionSetAssignment> toAdd = new List<PermissionSetAssignment>();
for (PermissionSet ps : [SELECT Id FROM PermissionSet WHERE Name IN :want]) {
if (!have.contains(ps.Id)) toAdd.add(new PermissionSetAssignment(AssigneeId = UserInfo.getUserId(), PermissionSetId = ps.Id));
}
if (!toAdd.isEmpty()) insert toAdd;
System.debug('Assigned ' + toAdd.size() + ' commissioning permission set(s).');
Seed the system hierarchy with the System ToolkitAdmin
On the Project's Commissioning tab, the System Toolkit lets you pick published templates (Opti pre-selects the checklist-backed ones) and seed them onto the project as a parent/child Systems & Equipment hierarchy — like a junction action manager for systems.
Step 0 already seeds a Door + Camera so downstream steps work immediately; use the Toolkit here to add more and watch the matrix update.
Ingest contractor progressCustomer User / Contractor
Contractors report checklist progress two ways: the admin/customer user pastes a CSV into the Contractor Sheet Import card, or an integration updates the systems directly. The Apex below simulates a contractor completing checklists across every seeded system on the project.
Id projId = 'a1KE20000095r9lMAA';
List<CitiriOS__System_Equipment__c> eq = [
SELECT Id, CitiriOS__Display_Name__c
FROM CitiriOS__System_Equipment__c
WHERE CitiriOS__Project__c = :projId
];
for (CitiriOS__System_Equipment__c e : eq) {
e.CitiriOS__Components_Total_Count__c = 4;
e.CitiriOS__Components_Verified_Count__c = 4;
e.CitiriOS__Checklist_Complete__c = true;
e.CitiriOS__Checklist_Status__c = 'Complete';
e.CitiriOS__Status__c = 'Tested';
e.CitiriOS__Stage__c = 'Handover_Prep';
}
update eq;
System.debug('Checklist completed for ' + eq.size() + ' systems.');
Monitor the Commissioning MatrixExecutive / Governance
The read-only Commissioning Matrix rolls up every top-level system on the project: stage, status, verified/total components, checklist status, and scheduled commissioning date. After Step 3, the Door row should show completed components and a "Complete" checklist.
Drill into a System recordCustomer User / Contractor
The System & Equipment record page has its own Commissioning tab showing child components and attached files. This is where a customer user inspects an individual system (the seeded Door 1000) and its sub-components (Camera A).
Advance the readiness gateExecutive / Governance
Once systems are tested, governance advances the Readiness Certification control gate. In the UI, use the Commissioning Governance card's gate action (requires COS_Advance_Commissioning_Gate). The Apex below simulates an executive passing the gate.
Id gateId = 'a0LE200000Oki8HMAR';
CitiriOS__Control_Gate__c g = [
SELECT Id, CitiriOS__Status__c FROM CitiriOS__Control_Gate__c WHERE Id = :gateId
];
g.CitiriOS__Status__c = 'Passed';
g.CitiriOS__Evaluated_By__c = UserInfo.getUserId();
g.CitiriOS__Evaluation_Date__c = Datetime.now();
update g;
System.debug('Readiness gate advanced to Passed.');
Passing a gate requires the COS_Make_Gate_Decision permission (carried by the admin PSG). A standard user without it will be blocked — the intended defense-in-depth behavior.
Decide the Inspection Request (IR#)Executive / Governance
The final governance action is accepting or rejecting an externally-issued Inspection Request. The seed created one (Submitted). Use the Commissioning Governance card's IR action (requires COS_Decide_Inspection_Request), or the Apex below to simulate acceptance.
Id irId = 'a1NE20000088l5BMAQ';
CitiriOS__Readiness_Attestation__c a = [
SELECT Id, CitiriOS__Status__c FROM CitiriOS__Readiness_Attestation__c WHERE Id = :irId
];
a.CitiriOS__Status__c = 'Accepted';
a.CitiriOS__Reviewed_By__c = UserInfo.getUserId();
a.CitiriOS__Review_Date__c = Datetime.now();
update a;
System.debug('Inspection request accepted.');
Known scratch-org caveat — Inspection Request Number field
In this particular scratch org the Inspection_Request_Number__c field failed to materialize (a source-tracking/sync artifact). The Commissioning Governance card's IR# list reads that field, so it may show an error while gates work normally. To restore it, create a Text field Inspection Request Number (API Inspection_Request_Number__c, length 80, External ID, Unique) on Readiness Attestation in Setup, or recreate the scratch org from source. The gate flow (Step 6) is unaffected.
Reset the walkthroughAdmin
Return the project to a clean pre-demo state (removes seeded systems, gates, and the inspection request; keeps the Program/Project so links stay valid). Re-run Step 0 to reseed.
Show reset Apex
Set<Id> projIds = new Map<Id, CitiriOS__Project__c>([
SELECT Id FROM CitiriOS__Project__c WHERE Name = 'RCT Walkthrough Project'
]).keySet();
delete [SELECT Id FROM CitiriOS__Readiness_Attestation__c WHERE CitiriOS__Project__c IN :projIds];
delete [SELECT Id FROM CitiriOS__Control_Gate__c WHERE CitiriOS__Project__c IN :projIds];
delete [SELECT Id FROM CitiriOS__System_Equipment__c WHERE CitiriOS__Project__c IN :projIds AND CitiriOS__Group__c != null];
delete [SELECT Id FROM CitiriOS__System_Equipment__c WHERE CitiriOS__Project__c IN :projIds];
System.debug('Walkthrough data reset. Re-run Step 0 to reseed.');