Creating Associations

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:

Product.new[productId='P1', name='Lettuce']
Product.new[productId='P2', name='Filet Mignon']
Product.new[productId='P3', name='Apple']

To add ProductGroup records, I have:

ProductGroup.new[productGroupId='PG1', 'Produce']
ProductGroup.new[productGroupId='PG2', 'Meat']

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

 We’ll consider three cases:Neither Products nor Product groups already exist and need to be created by the rules.

  1. The Product groups already exist but the Products need to be created and associated.
  2. Both the Product groups and the Products exist and must be associated.

 

Also see Generating Test Data :https://community.progress.com/community_groups/corticon/m/documents/1368.aspx

and Custom Messages https://community.progress.com/community_groups/corticon/m/documents/1267.aspx