This is a very complex example: a recursive deep copy, using reactive logic. For more information:
RequirementWhen a kit (Product consisting of other component products) is ordered, we must reduce the quantity of all the components parts, recursively. So, ordering a Boing 747 reduces the bolts quantities repeatedly, for the fuselage, wings, and so forth. The following image illustrates the database structure: SolutionWhile described here as a separate topic, the Bill of Materials Kit Explosion example is a requirement within Place Order. When ordering a Product that is a kit (that is, composed of other Parts, such as a plane with Wings), you want to reduce inventory for each of the components of the kit. The following image shows the solution on the Manage, Rules, By Topic tab: The key requirement is to populate the if (logicContext.verb == "INSERT" && row.product.count_components > 0) { SysLogic.insertChildrenFrom("lineitems", row.product.components, logicContext); } The remaining logic (four rules) is to properly arrange for quantities (that is, if you buy two planes, you need eight engines). SubItems are a child of LineItem objects, representing the bill of materials explosion. The solution is to use the Insert Into From rule extension: see the first action rule in the following image. The The solution requires four rules. The following image shows the complete event definition on the Manage, Rules, Event page: This even definition recursively creates the sub-items from each item. The complete definition of Explore the Bill of Materials Kit ExplosionYou can use the REST Lab to POST the following to a URL such as: http://.../APICreator/rest/demo/sample/v1/cust.orders_c { "customer" : "Alpha and Sons" , "IsReady" : false , "items_o" : [ { "ProductName" : "Boing 747" , "QuantityOrdered" : 2 } ] } |
Getting Started > Reactive Logic Tutorial >