@@ -149,6 +149,68 @@ Every fieldInstance requires:
149149- Must have ` fieldInstanceProperties ` with ` uiBehavior `
150150- Use ` Record.{Field} ` format
151151
152+ ### 5. Unique Identifiers and Region Names (CRITICAL - PREVENTS DUPLICATE ERRORS)
153+
154+ ** EVERY identifier and region/facet name MUST be unique across the entire FlexiPage file.**
155+
156+ ** Critical Rules:**
157+ - ❌ ** NEVER create two ` <flexiPageRegions> ` blocks with the same ` <name> ` **
158+ - ✅ ** If multiple components belong to same facet, combine them in ONE region with multiple ` <itemInstances> ` **
159+ - ❌ ** NEVER reuse the same ` <identifier> ` value**
160+ - ✅ ** Always read entire file first and extract ALL existing identifiers and names**
161+
162+ ** Wrong - This WILL FAIL with duplicate name error:**
163+ ``` xml
164+ <!-- First field section in detail tab -->
165+ <flexiPageRegions >
166+ <itemInstances >
167+ <componentInstance >
168+ <identifier >flexipage_property_details_fieldSection</identifier >
169+ ...
170+ </componentInstance >
171+ </itemInstances >
172+ <name >detailTabContent</name > <!-- ❌ DUPLICATE NAME -->
173+ <type >Facet</type >
174+ </flexiPageRegions >
175+
176+ <!-- Second field section in detail tab -->
177+ <flexiPageRegions >
178+ <itemInstances >
179+ <componentInstance >
180+ <identifier >flexipage_pricing_fieldSection</identifier >
181+ ...
182+ </componentInstance >
183+ </itemInstances >
184+ <name >detailTabContent</name > <!-- ❌ DUPLICATE NAME - DEPLOYMENT FAILS -->
185+ <type >Facet</type >
186+ </flexiPageRegions >
187+ ```
188+
189+ ** Correct - Combine itemInstances in ONE region:**
190+ ``` xml
191+ <!-- Both field sections in same detail tab facet -->
192+ <flexiPageRegions >
193+ <itemInstances >
194+ <componentInstance >
195+ <identifier >flexipage_property_details_fieldSection</identifier >
196+ ...
197+ </componentInstance >
198+ </itemInstances >
199+ <itemInstances >
200+ <componentInstance >
201+ <identifier >flexipage_pricing_fieldSection</identifier >
202+ ...
203+ </componentInstance >
204+ </itemInstances >
205+ <name >detailTabContent</name > <!-- ✅ ONE REGION, MULTIPLE COMPONENTS -->
206+ <type >Facet</type >
207+ </flexiPageRegions >
208+ ```
209+
210+ ** When to combine vs separate:**
211+ - ** Combine** : Components that logically belong to same tab/section (e.g., multiple field sections in detail tab)
212+ - ** Separate** : Components that belong to different tabs/sections (e.g., ` detailTabContent ` vs ` relatedTabContent ` )
213+
152214---
153215
154216## Common Deployment Errors
@@ -178,7 +240,7 @@ Every fieldInstance requires:
178240** Fix:** Use "Volunteer_Record_Page" not "Volunteer__ c_Record_Page"
179241
180242### "Region specifies mode that parent doesn't support"
181- ** Cause:** Added ` <mode> ` tag to region
243+ ** Cause:** Added ` <mode> ` tag to region
182244** Fix:** Remove ` <mode> ` tags - they're not needed for standard regions
183245
184246---
@@ -211,21 +273,28 @@ When user provides an existing FlexiPage file path:
211273
2122741 . ** Read the file** using native file I/O
2132752 . ** Parse XML** to extract:
214- - Existing component identifiers
276+ - ** ALL existing component identifiers** (search for all ` <identifier> ` tags)
277+ - ** ALL existing region/facet names** (search for all ` <name> ` tags in ` <flexiPageRegions> ` )
215278 - Available regions (parse from file, don't assume names)
216279 - Existing facets
217- 3 . ** Generate component XML** (apply all rules from "Critical XML Rules" section)
218- 4 . ** Insert** into appropriate region
219- 5 . ** Write** modified XML back to file
220- 6 . ** Deploy** : ` sf project deploy start --source-dir force-app/... `
280+ 3 . ** Verify uniqueness** - ensure your new identifiers and names don't conflict with ANY existing ones
281+ 4 . ** Check if target facet exists** - if adding to a named facet like ` detailTabContent ` that already exists:
282+ - ** Add new ` <itemInstances> ` to existing region** (don't create duplicate region)
283+ - ** Insert before the closing ` </flexiPageRegions> ` tag of that region**
284+ 5 . ** Generate component XML** (apply all rules from "Critical XML Rules" section)
285+ 6 . ** Insert** into appropriate region or add itemInstances to existing facet
286+ 7 . ** Write** modified XML back to file
287+ 8 . ** Deploy** : ` sf project deploy start --source-dir force-app/... `
221288
222289---
223290
224291### Generating Unique Identifiers
225292
226- ** Algorithm** :
293+ ** CRITICAL: Before generating ANY new identifier or facet name, follow the rules in section 5 of "Critical XML Rules" above.**
294+
295+ ** Identifier Generation Algorithm** :
227296```
228- 1. Extract all existing <identifier> values from XML
297+ 1. Extract ALL existing <identifier> AND <name > values from XML
2292982. Generate base name: {componentType}_{context}
230299 Examples: "relatedList_contacts", "richText_header", "tabs_main"
2313003. Find first available number:
@@ -253,6 +322,11 @@ When user provides an existing FlexiPage file path:
253322 - Example: ` Facet-66d5a4b3-bf14-4665-ba75-1ceaa71b2cde `
254323 - Use for field section columns, nested containers, anonymous slots
255324
325+ ** When adding components to existing files:**
326+ - Check if target facet name already exists
327+ - If exists: Add new ` <itemInstances> ` to that existing region (see section 5 above for details)
328+ - If doesn't exist: Create new region with unique name
329+
256330---
257331
258332### Region Selection
@@ -401,6 +475,9 @@ Identifier Pattern: flexipage_richText or flexipage_richText_{sequence}
401475
402476Before deploying:
403477- [ ] Used CLI to bootstrap (don't start from scratch)
478+ - [ ] ** ALL identifiers are unique** - no duplicate ` <identifier> ` values anywhere in file
479+ - [ ] ** ALL region/facet names are unique** - no duplicate ` <name> ` values in ` <flexiPageRegions> `
480+ - [ ] ** Multiple components in same facet are combined** - ONE region with multiple ` <itemInstances> ` , NOT separate regions with same name
404481- [ ] All field references use ` Record.{Field} ` format
405482- [ ] Each fieldInstance has ` fieldInstanceProperties ` with ` uiBehavior `
406483- [ ] Each fieldInstance in own ` <itemInstances> ` wrapper
0 commit comments