Identifying Child Objects Scenario

It can be beneficial to use a calculated attribute to easily identify if a product family has any children. For example, it can be beneficial to run an export of product families, and have a clear indication of whether the family has no child products, one single child product, or more than one child product.

Assumptions

  1. The calculated attribute is valid for specific 'parental' product object types.
  2. The subsequent export specifies the appropriate object type(s) to be exported.
  3. This simple calculation will check all child products below the selected product family object type, which includes all subordinate levels.
  4. If a calculation is required to restrict the levels to a specific number of children, a more sophisticated calculation will be required.

Solution

Approach

A simple list of child products will be obtained. The list will then be checked if it has 0 length (no children) or if it has a length of 1 (a single child product), and if neither of those two criteria are met then the family is assumed to have more than one child product.

Value Template

{childlist := subproducts()}
if(listlen(childlist)=0, "None", if(listlen(childlist)=1, "Single Child", "Multiple Children"))

For information on adding a value template, refer to the Attribute Editor section of the Function Editor documentation here.

Results

The first node selected has no children, so 'None' is displayed.

The second node selected has one child, so 'Single Child' is displayed.

The third node selected has more than one child, so 'Multiple Children' is displayed.