UPDATE:  This blog posting has become obsolete with the introduction of Calculations in Dynamics AX 2012 R2 CU6.  Please see the following blog posting for more details.



The constraint based product configurator was released in Dynamics AX 2012.  The bulk of the constraint logic can be built using Microsoft Solver Foundation logic, as described in the following technet article.


There are some limitations to what can be accomplished through the solver foundation.  For example, product configurator does not support the use of decimal values in constraint calculations and as a result prohibits many calculations involving multiplication and division.

One way to meet these requirements is to make use of the newly introduced PCAdaptor class.  The following example shows how to use this class to calculate a decimal quantity for a BOM Line as the square of an integer divided by 3.  In many cases this
type of calculation would result in decimal values, so it could not be accommodated using the solver foundation logic.

Our calculation will be:

                BOM Quantity = (Integer1^2)/3

 We will be using a very basic product configuration that consists of one attribute and no constraints.  This example uses the contoso USA demo data .

Basic Product Model Setup

Product Model: CalculationExample



Solver Name


Attribute Type






BOM Lines



Item Number


1101 Name





X++ Code to calculate the required quantity.

In order to call the API we will need to create a new class in the AOT that extends the PCAdaptor class. 
I’ve created a new class called ModelCalcExample.  The classDeclaration method for this class is shown below.  Note that the
PCAdaptorExtensionAttribute must be used to indicate that this class is associated with my CalculationExample product model.

[PCAdaptorExtensionAttribute('CalculationExample')]//Model Name

public class ModelCalcExample extends PCAdaptor



Next I will need to include some code in the run method of my class.  This code will execute after I
have made all attribute selections and click on the Ok button.

public void run()


    str   100    INT1;

    real   QTY;

PCAdaptorAttribute  attr;   
PCAdaptorRootComponent rootComponent;

rootComponent = this.parmProductConfigurationModel().getRootComponent();

attr = rootComponent.getAttribute('INTEGER1');

         INT1  = attr.getValueAsLocalizedString();

         QTY = (str2int(INT1)*str2int(INT1))/3;


rootComponent.getBOMLine('1101 Name').parmturnoverquantity(QTY);




Now that we’ve written this code, we can test the results.  If you assign this product
configuration model to a configurable item, and test using an integer value of
13 you should get a 1 line BOM for your item that contains Item Number 1101
with a quantity of 56.3333.

This is only one example of what can be done using the API with constraint base product models.  There are many other parameter values that can
be set on both BOM’s and Routes.  Some examples include calculating the run time of a route operation, setting the
scrap factor on a BOM line, and setting route operation priority.  You can get a feel for the possibilities by
reviewing the methods within the PCAdaptorBOMLine and PCAdaptorRouteOperation classes.