Working with Collections

  • Updated

The Collection element defines the relationship between a parent entity and its collection of child entities or local "complex" structures. The association is made in the Data Type dropdown list, which is populated with a list of defined entities.

Adding a collection

Right-click on the element to which you want to add to. Select Add -> Collection


Deleting a collection

There are a few ways to do this:

  1. Right-click on the collection you wish to delete, and select Delete.
  2. Click on the collection you wish to delete and click Delete on the Home Banner.
  3. Click on the collection you wish to delete and hit the Delete key on your keyboard

You will be prompted to confirm the deletion. Click Yes.




Specifies the name of the collection.

Try to make the name of the collection plural, or more specifically the plural of the entity name contained within the collection. This will help others infer that it is a collection and what it's a collection of.

Display Name

Specifies the name that will be used in the business language editor when referring to this field.

Data Type

Specifies the data type of the collection. The data type can either be another entity definition or a complex data type. All existing entity types are available in the drop-down combo box in addition to the complex data type.

Entity Collections

  • Most commonly used over complex collections
  • Fields are defined on the entity to which the collection refers
  • Have their own rule context (e.g. rules can be authored against Entity1.Collection1 if Collection1 is an entity collection)

Complex Collections

  • Less commonly used vs. entity collections
  • Fields are defined inline in the entity structure beneath the complex collection
  • Do not have their own entity rule context. All rules must be written at the parent entity level. This can lead to complexity in nested complex collection scenarios.
  • To add fields to a complex collection, right-click on the collection in the entity tree and select Add > Field, Calculation or Collection.


If Entity is selected for Data Type, the Entity type is selected here.

Parent Context

If Entity is selected for Data Type, checking this box will allow rules running on the collection's entity type to reference fields on this entity, the parent.


Clicking on the hyperlink will navigate to the Vocabulary folder for the entity in which this collection is contained.


For collections that have a Data Type of Entity, a Context rule set can be defined with the collection to manage rules that are specific to the context in which the entity is used within the collection.

Using Collections to Establish a Hierarchy

In many situations, a rule application needs to operate over a hierarchy of data rather than a flat set of related fields. InRule allows you to create relationships between entities to establish a parent-child relationship.

For example, a standard company invoice usually has a set of information that relates to the invoice header such as company name, address, billing contact, etc. In addition, there is a collection of line items that comprise the detailed billing section of the invoice. While there are rules that may apply only to the header information or to individual line items, there are also rules that apply to the items as a whole. For example, suppose you wanted a rule that looked at the total amount across all the line items and the customer ID and assigned a discount to the total invoice amount. This can be difficult without the existence of a parent-child structure.

Using Collection Functions

When using functions that operate on collections, the first parameter is always a collection. For example, if you want to sum the amount field in a collection of line items, the syntax would appear like the following:

Sum(LineItems, ItemAmount)

Syntax to lookup a data element from a collection:

CollectionLookup(Vehicles, ID, Year=1999 And Make="Ford", "N/A")

Collections are a powerful construct for aggregate and relational rules processing, but they also introduce degrees of complexity that may not be apparent until specific situations call for it. Special functions can be applied to manage a variety of logic scenarios relating to the use of collections - these include @Index, CurrentContext(), and OuterContext().

For a list of available collection functions, please see the Function Reference.

Was this article helpful?

0 out of 0 found this helpful



Please sign in to leave a comment.