layout | title | parent | grand_parent | nav_order |
---|---|---|---|---|
default |
Capacity Management Flows |
Capacity Management Implementation |
Implementation Guides |
4 |
This guide provides detailed instructions for implementing the automated flows that enforce capacity constraints and maintain buffer management in the BoxFresh app's Theory of Constraints implementation.
Capacity management requires two key automated flows:
- Capacity Check Flow: Validates material stock changes against container capacity constraints
- Container Update Flow: Recalculates container capacity metrics when material stocks change
Together, these flows ensure:
- Containers never exceed their defined capacity
- Buffer zones (red/yellow/green) are properly maintained
- Alerts are created when containers cross buffer thresholds
- Container capacity metrics remain accurate and up-to-date
The Capacity Check Flow verifies that material stock changes won't exceed container capacity constraints and generates alerts when buffer thresholds are crossed.
- When a new Material_Stock__c record is created
- When an existing Material_Stock__c record's Units_Consumed__c or Inventory__c fields are updated
-
Capacity Validation:
- Calculate the container's available capacity
- Check if the material stock change would exceed capacity
- Block the change if capacity would be exceeded
-
Buffer Threshold Monitoring:
- Track if container crosses buffer thresholds (30% and 70%)
- Create alerts when thresholds are crossed
- Navigate to Setup > Flow Builder > New Flow
- Select Record-Triggered Flow
- Configure trigger:
- Object: Material_Stock__c
- Trigger When: A record is created or updated
- Entry Criteria: [Units_Consumed__c] > 0 OR [Inventory__c] CHANGES
- Optimization: Run only when specified changes are made
- Run Asynchronously: Unchecked
Create these flow variables:
- containerAvailableBefore (Number)
- containerAvailableAfter (Number)
- stockUnitsBeforeChange (Number)
- newUnitsConsumed (Number)
- inventoryId (Text)
- wasOverThreshold (Boolean)
- isOverThreshold (Boolean)
- wasUnderThreshold (Boolean)
- isUnderThreshold (Boolean)
-
Get Old Stock Data (Get Records element)
- Object: Material_Stock__c
- Filter: Id Equals {!$Record.Id}
- Store Units_Consumed__c and Inventory__c values
-
Get Container Data (Get Records element)
- Object: Inventory__c
- Filter: Id Equals {!$Record.Inventory__c}
- Store all fields
-
Calculate Available Capacity (Assignment element)
- containerAvailableBefore = Current container available units + Units consumed before change
- newUnitsConsumed = New units consumed value
- containerAvailableAfter = Available before - New units consumed
- Calculate threshold crossing flags:
- wasOverThreshold = Current utilization >= 70%?
- isOverThreshold = New utilization >= 70%?
- wasUnderThreshold = Current utilization <= 30%?
- isUnderThreshold = New utilization <= 30%?
-
Check Capacity (Decision element)
- Rule: containerAvailableAfter < 0
- If true, show error screen
- If false, proceed to threshold check
-
Check Threshold Crossing (Decision element)
- Rule 1: wasOverThreshold = false AND isOverThreshold = true (crossed upper threshold)
- Rule 2: wasUnderThreshold = false AND isUnderThreshold = true (crossed lower threshold)
- Default: No threshold crossed
-
Create Upper Alert (Create Records element)
- Object: Task
- Subject: "Container Above Buffer: " + Container Name
- Description: Details about reaching upper threshold
- Priority: High
-
Create Lower Alert (Create Records element)
- Object: Task
- Subject: "Container Below Buffer: " + Container Name
- Description: Details about reaching lower threshold
- Priority: Medium
Add a Screen element to display when capacity would be exceeded:
- Heading: Capacity Limit Exceeded
- Message: The material would exceed the container's capacity by {amount} units
- Back button to allow user to revise their input
The Container Update Flow keeps container capacity metrics synchronized with the actual material stock stored within the container.
- When a Material_Stock__c record is created, updated, or deleted
- When the Units_Consumed__c field is changed
- When the Inventory__c relationship is changed
-
Context Determination:
- Determine if this is a container change or single container update
- Identify the affected container(s)
-
Capacity Recalculation:
- Recalculate total units consumed
- Update available units, capacity utilization, and buffer status
- Navigate to Setup > Flow Builder > New Flow
- Select Record-Triggered Flow
- Configure trigger:
- Object: Material_Stock__c
- Trigger When: A record is created, updated, or deleted
- Condition Requirements:
- Created: No conditions
- Updated: [Units_Consumed__c] is changed OR [Inventory__c] is changed
- Deleted: No conditions
- Run Asynchronously: Unchecked
- Trigger Timing For Update/Create: After the record is saved
- Trigger Timing For Delete: Before the record is deleted
Create flow variables:
- containerIdOld (Text)
- containerIdNew (Text)
- recordUnitsConsumed (Number)
- isDeleted (Boolean)
- isCreated (Boolean)
- isUpdated (Boolean)
-
Context Variables (Assignment element)
- Determine operation type (create/update/delete)
- For updates, capture old and new container IDs
- Track units consumed value
-
Container Change Decision (Decision element)
- Check if this is a container change or single container update
- Branch flow accordingly
- Get Container Data (Get Records elements)
- Get container details (new container, and old container if changed)
- For each container, get all related material stocks
- Sort and Loop (Loop elements)
- Sort material stocks by priority
- Calculate total consumption for each container
- Prepare values for container updates
- Update Container Records (Update Records elements)
- Update each affected container with:
- Total_Units_Consumed__c = Sum of all Units_Consumed__c
- Available_Units__c = Capacity_Units__c - Total_Units_Consumed__c
- Capacity_Utilization_Percent__c = (Total/Capacity) * 100
- Buffer_Status__c = Based on utilization percent thresholds
- Update each affected container with:
- Create an Inventory__c record with Capacity_Units__c = 100
- Create a Material_Stock__c record with Units_Consumed__c = 60
- Expected results:
- Record created successfully
- Container updated with 60% utilization
- Alert created for crossing into yellow zone
- Try to create a second Material_Stock__c with Units_Consumed__c = 50
- Expected results:
- Error shown (exceeds capacity by 10 units)
- Change blocked
- Create a second Inventory__c with Capacity_Units__c = 200
- Move the Material_Stock__c to the second container
- Expected results:
- First container updated to 0% utilization
- Second container updated to 30% utilization
- Both containers' metrics recalculated correctly
- For high-volume operations, consider Apex triggers for better performance
- Make threshold values (30%/70%) configurable via custom settings
- Add appropriate error handling for edge cases
- Consider batch processing for handling large volumes of records
- Inventory Capacity Fields - Implementing the container capacity fields
- Material Stock Capacity Fields - Implementing capacity consumption fields
- Assignment Junction Relationship - Creating the junction relationship
- Validation Rules - Additional validation rules for capacity management
This guide was consolidated from the original implementation guides capacity_check_flow.md
and container_update_flow.md
as part of the Documentation Consolidation Initiative (April 3-11, 2025).