Flow Name: On Product: Assign Product Categories¶
Last Updated: 2024-08-14 Source Code: On_Product_Assign_Product_Categories.flow-meta.xml
API Name: On_Product_Assign_Product_Categories Status: Active Type: Custom Trigger: After Save on Product2 record when IsVisibleInProductCatalog__c field changes
Business Purpose¶
Automatically manages product category assignments based on product visibility and category configuration. Assigns products to appropriate categories for catalog display and removes assignments when products become invisible.
Process Flow¶
- Visibility Check: Evaluates if product IsVisibleInProductCatalog__c is true
- Category Retrieval: Gets all ProductCategory records from the system
- Category Filtering: Filters categories to match:
- Product_Category__c field value
- Root_Category__c field value
- Category named "Products"
- Assignment Cleanup: Deletes existing ProductCategoryProduct assignments for the product
- New Assignments: Creates new ProductCategoryProduct records for filtered categories
- Invisible Product Handling: For invisible products, assigns to "IsNotvisibleincatalog" category
📊 Click to view Process Flow Diagram
flowchart TD
Start([Start: After Save on Product2 record when IsVisibleInProductCatalog__c field changes]) --> Lookup[Lookup Related Data]
Lookup --> Found{Data<br/>Found?}
Found -->|No| End([End])
Found -->|Yes| Calculate[Calculate/Determine Values]
Calculate --> Update[Update Records]
Update --> End
style Start fill:#e1f5ff
style Lookup fill:#f0e1ff
style Found fill:#fff4e1
style Calculate fill:#e1ffe1
style Update fill:#ffe1e1
style End fill:#e1f5ff
Key Business Rules¶
- Only processes when IsVisibleInProductCatalog__c field changes
- Visible products assigned to categories based on Product_Category__c, Root_Category__c, and "Products"
- Invisible products assigned to special "IsNotvisibleincatalog" category
- Deletes all existing category assignments before creating new ones
- Bulk processes category assignments for efficiency
Dependencies¶
- Product2 object with fields: IsVisibleInProductCatalog__c, Product_Category__c, Root_Category__c
- ProductCategory object with Name field
- ProductCategoryProduct junction object for assignments
- Special ProductCategory named "IsNotvisibleincatalog"
Changes¶
PR-29111: On is Visible on Categories field change: Assign Categories to be shown on Portal based on Root Category and Product Category fields
⚠️ Pre-Go-Live Concerns¶
CRITICAL - Fix Before Go-Live¶
- Special Category Dependency: Flow fails if "IsNotvisibleincatalog" category doesn't exist
- Category Name Dependencies: Logic relies on exact category names matching product field values
HIGH - Address Soon After Go-Live¶
- Bulk Assignment Performance: Could timeout with large numbers of products/categories
- Assignment Deletion: Deletes all assignments before recreating, causing temporary display issues
- "Products" Category: Hard-coded reference to "Products" category may not exist
MEDIUM - Future Enhancement¶
- Add error handling for missing categories
- Implement incremental assignment updates instead of delete/recreate
- Add validation that required categories exist before assignment
- Consider caching category lookups for performance
LOW - Monitor¶
- Performance with high-volume product catalog updates
- Category assignment synchronization timing
- Impact of temporary assignment deletion on user experience
Maintenance Notes¶
Complex flow with multiple category filtering and assignment logic. Monitor for performance issues with large product catalogs. Ensure special categories ("Products", "IsNotvisibleincatalog") exist and maintain consistent naming. Consider refactoring delete/recreate pattern for better performance.