Example: B2C Product and Category Mappings

Hierarchical Categories and Products in B2C Service can be loaded for use in rules and on screens, provided they are loaded dynamically. The to-many relationship between Product and Category can also be loaded once a single Category (or Product) is selected, via an entity with a to-one relationship from Global.

The following worked example is provided to demonstrate this. This example allows the user to select a category and then subcategories down to its lowest level and from there load the product mapped to that final selection.

To do this, there is a to-many relationship (all instances of the product for the selected category) from the selected category entity to the product entity.

The Edit Relationship dialog in Policy Modeling showing the relationship from the selected category entity to the product entity

This can be loaded once a Category is selected via the selected category entity that has a to-one relationship (the selected category) from the Global entity.

The Edit Relationship dialog in Policy Modeling showing the relationship from the Global entity to the selected category entity

The interview loads all top level categories (instances of the level 1 category entity) and then sub-categories (instances of the level 2 category entity, the level 3 category entity and the level 4 category entity) based on the user's selection.

The Data tab in Policy Modeling showing the entity structure for a category and product data model

The Edit Entity dialog in Policy Modeling showing the selected the level 1 entity

The Edit Entity dialog in Policy Modeling showing the selected the level 2 entity

The Edit Entity dialog in Policy Modeling showing the selected the level 3 entity

The interview then loads the product(s) related to the user's lowest selected sub-category.

The selection of a loaded product on a category interview screen in Intelligent Advisor

The rules used to determine the selected categories at each level are as follows.

The following four rules pull the ID of the selected category at each level up to an attribute at the global level:

the selected level 1 category id = the level 1 category id, in the case of the selected level 1 category

the selected level 2 category id = the level 2 category id, in the case of the selected level 2 category

the selected level 3 category id = the level 3 category id, in the case of the selected level 3 category

the selected level 4 category id = the level 4 category id, in the case of the selected level 4 category

The following rules determine whether any child categories exist, for the purpose of determining which is the lowest selected category:

There are level 2 categories if

InstanceCount(all instances of the level 2 category) > 0

There are level 3 categories if

There are level 2 categories and

InstanceCount(all instances of the level 3 category) > 0

There are level 4 categories if

There are level 3 categories and

InstanceCount(all instances of the level 4 category) > 0

and for the purpose of hiding subsequent questions on the interview screen:

The screen layout view in Policy Modeling showing when the sub-categories are shown

The following tables determine the name and ID of the last category (the category furthest down the hierarchy of categories) that has been selected:

Table 1. Rule table to determine the ID of the lowest selected category
the ID of the lowest selected category
For(the selected level 4 category, the level 4 category ID) There are level 4 categories
For(the selected level 3 category, the level 3 category ID) There are level 3 categories
For(the selected level 2 category, the level 2 category ID) There are level 2 categories
For(the selected level 1 category, the level 1 category ID) otherwise
Table 2. Rule table to determine the name of the lowest selected category
the name of the lowest selected category
For(the selected level 4 category, the level 4 category name) There are level 4 categories
For(the selected level 3 category, the level 3 category name) There are level 3 categories
For(the selected level 2 category, the level 2 category name) There are level 2 categories
For(the selected level 1 category, the level 1 category name) otherwise

The ID is used to dynamically load the selected category’s products. (The name is used for Debugging only.)

The Edit Entity dialog in Policy Modeling showing the selected category entity

The following rules are used to determine if the products have been loaded:

the products have been loaded if

ForAll(the selected category, the selected category’s products have been loaded)

the selected category’s products have been loaded if

InstanceCount(all instances of the product for the selected category)>0

This is for the purpose of only showing the product list on the interview screen after the products have been dynamically loaded:

The screen layout view in Policy Modeling showing when the product list is shown

Once the user has selected a product from the list of dynamically loaded product entities, the following rules move the product name and ID to the Global entity so it is easier to use on screens, in documents and so on.

the name of the selected product = For(the selected product, the product name)

the ID of the selected product = For(the selected product, the product ID)