Create dynamic, data-driven interfaces with different layouts based on item properties using collection prototypes.
Collection prototypes allow you to display items within a collection using different layouts based on their properties, creating more dynamic and context-aware user interfaces.
Collection prototypes are specialized components that define different display formats for items within a single collection. They act as templates that are applied conditionally based on item properties, allowing you to:
Display collection items with different layouts based on their data properties
Create visually distinct displays for featured or highlighted items
Apply specialized formatting for different item types or states
Integrate custom components for enhanced functionality
Add interactive features like item selection
Collection prototypes always work as child components within a parent Collection component. While a Collection iterates through a data array, Collection Prototypes determine how each individual item should be displayed.
Collection prototypes use a simple but powerful mechanism to determine which layout to apply to each item. The behavior depends on whether you have one or multiple prototypes:
Prototype Identifier Key (PIK)
The data property used to determine which prototype to apply (e.g., type, status, priority)
Prototype Identifier Value (PIV)
The specific value that triggers this prototype layout (e.g., featured, active, high)
Configuration: PIK and PIV are optional and should not be configured
If you have only one collection prototype, the system will automatically use that prototype for all items in the array, regardless of their properties. In this case, leave both PIK and PIV empty.
Configuration: PIK and PIV are required and both must be completed
When using multiple collection prototypes, both PIK and PIV must be properly configured for each prototype. The configuration is only valid if both fields are completed.
When the collection renders, each item is evaluated against all available prototypes. The first prototype whose identifier key and value match the item’s data is used to render that item.
Use case: Displaying a list of menu items where all items have the same layout
Report incorrect code
Copy
Ask AI
// Data structure - all items use the same prototype[ { "name": "Margherita Pizza", "price": 12.99, "description": "Classic tomato and mozzarella" }, { "name": "Caesar Salad", "price": 8.99, "description": "Fresh romaine with parmesan and croutons" }]
Configuration:
PIK: (leave empty)
PIV: (leave empty)
Since all items use the same layout, no prototype identification is needed.
Use case: Restaurant menu with different layouts for main courses vs desserts
Report incorrect code
Copy
Ask AI
// Data structure with type field for prototype identification[ { "name": "pizza", "type": "main course", "price": 15.99, "ingredients": ["tomato", "mozzarella", "basil"] }, { "name": "cremsnit", "type": "dessert", "price": 6.99, "sweetness": "medium" }]
Configuration for main course prototype:
PIK: type
PIV: main course
Configuration for dessert prototype:
PIK: type
PIV: dessert
Each item’s type property determines which prototype layout to use.
The most common approach is to use a Service Task node with business rules:
1
Add a Service Task Node
In the FlowX.AI Designer, add a Service Task node before your User Task node and connect them with a sequence flow.
2
Configure the Business Rule
Select your Service Task node, go to the Business Rules tab, and add a new business rule or edit an existing one.
3
Write the Data Preparation Code
Use JavaScript to create your data structure and assign it to the process context:
Report incorrect code
Copy
Ask AI
// Create the data structure for productsconst products = [{ "name": "Product One Plus", "description": "The plus option", "type": "normal", // This property will determine which prototype to use "price": 99.99},{ "name": "Product Two Premium", "description": "This is premium product", "type": "recommended", // This will use a different prototype "price": 149.99},{ "name": "Product Basic", "description": "The most basic option", "type": "normal", "price": 49.99}];// Add the products array to the process dataoutput.put("products", products);
4
Test Your Data
Save your configuration, and test your business rule by using the Test Rule feature in the business rules editor to make sure the data is correctly added to the process context.
Once your data is prepared, you can implement the collection and its prototypes in the UI Designer:
1
Create a User Task Node
In the FlowX.AI Designer, create or select an existing User Task node in your process and click the brush icon to open the UI Designer.
2
Add a Collection Component
Add a root component (like a Card or Container) to your node, then add a Collection component inside it. Configure the Collection’s source to point to your data array (e.g., products).
The collectionSource property specifies the process key where your list can be found. It should be a valid array of objects. For example, if your data is at processData.products, you would set the source to products.
3
Add Collection Prototypes
Single prototype (simple case)
Multiple prototypes (advanced case)
For a single prototype that applies to all items:
Click on your Collection component to select it
Add a Collection Prototype as a child component
Leave PIK and PIV empty - no configuration needed
The prototype will automatically apply to all items in the collection
This is the most common scenario when all items in your collection should have the same layout.
For different display types based on item properties:
Click on your Collection component to select it
Add a Collection Prototype as a child component
Configure the prototype’s settings:
Prototype Identifier Key: The field to check (e.g., type)
Prototype Identifier Value: The value to match (e.g., normal)
Repeat for each different prototype you need, using different identifier values
Both PIK and PIV must be configured for each prototype when using multiple prototypes.
4
Design Each Prototype's Layout
For each prototype, add the UI components that will display your data:
Select a Collection Prototype
Add components like Text, Image, Button, etc.
Configure each component to use relative paths to the collection item data saved in the Data Model:
Use text UI element with the key ${name}
Use text UI element with the key ${description}
Components within a collection use relative paths to the collection source. This means that wherever the collection is found inside the process data, the components inside the collection need their keys configured relative to that collection.
Can I use different layouts for mobile and desktop?
Yes, you can create platform-specific overrides for your collection prototypes. Configure different layouts, spacing, and styling for Web, iOS, and Android platforms through the platform tabs in the UI Designer.
How do I handle missing identifier values?
If an item doesn’t have the specified identifier key or value, it won’t match any prototype. Consider adding a default prototype with a common value like “default” and ensure all items have at least this value as a fallback.
When should I configure PIK and PIV vs leaving them empty?
Leave PIK and PIV empty when:
You have only one collection prototype
All items in your collection should use the same layout
Configure both PIK and PIV when:
You have multiple collection prototypes
Different items should display with different layouts based on their properties
Both fields must be completed for the configuration to work
This logic has been unchanged since 2021 and is a fundamental aspect of how collection prototypes work.
Can I use expressions in prototype identifier values?
No, prototype identifier values must be static strings that exactly match the values in your data. However, you can transform your data before it reaches the collection to achieve dynamic prototype selection.
Is there a limit to how many prototypes I can define?
There’s no hard limit on the number of prototypes, but for performance and maintainability reasons, it’s recommended to keep the number reasonable (typically under 5-7 different prototypes).
What's the difference between Collection and Collection Prototype?
A Collection is a container that iterates through an array of data items, while a Collection Prototype defines how each individual item should be displayed based on its properties. You need at least one Collection Prototype inside a Collection, but you can have multiple prototypes to handle different item types or states.