Use Case

I have an action-only rule sheet to seed some data for later rule sheets. I have a Product entity which has an N:1 association to a ProductGroup entity.

To add Product records, I have lines similar to this:[productId='P1', name='Lettuce'][productId='P2', name='Filet Mignon'][productId='P3', name='Apple']

To add ProductGroup records, I have:[productGroupId='PG1', 'Produce'][productGroupId='PG2', 'Meat']

So what is the syntax to associate the "Lettuce" product to the "Produce" product group?



We’ll consider three cases:

  1. Neither Products nor Product groups already exist and need to be created by the rules.
  2. The Product groups already exist but the products need to be created and associated.
  3. Both the Product groups and the products exist and must be associated.


Case 1: Creating Entirely New Objects

You use the += notation for one-to-many associations

With a vocab like this

And a rule sheet like this

You will get this:

Case 2: Adding to Existing Product Group Objects

If the product groups already exist then you might use something like this to add the products by using aliases to the product collections within the product groups:

newUnique can be used to avoid creating duplicate items


Case 3: Both Products and Groups already exist



Download PDF version.