Product Configuration Synchronous Execution
This blog post describes an new way of interacting synchronously from code with the
Constraint-Based Product Configurator which has been introduced in Microsoft
Dynamics AX 2012 R3 CU8.
The scenario that drove the introduction of this feature can be described as follows:
An external 3rd party sales configurator outside of Microsoft Dynamics AX 2012 is used to
assign values to a subset of attributes(a partially configured order), from
which the remaining mandatory attributes can have their values deduced using
the Microsoft Dynamics AX 2012 Configurator, thereby completing the order.
Once the all the values have been deduced, assuming all values are valid, they can be passed on
to the back end configuration module, which will create the BOM and potentially
the Route (if the model has a Route).
Included in Microsoft Dynamics AX 2012 R3 CU 8 is a new derived version of the PCRuntimeConfigurator class, named PCRuntimeSynchronousConfigurator.
This class is designed, as the name indicates, for synchronous interaction with the .NET
The configure method on the class is the method
which exposes the new functionality added to the .NET Configurator to Xpp. The
method takes three arguments; the model as xml, the attribute assignments as
xml and a the number of milliseconds which can be used before a timeout occur.
The return of the method is a IsConfigurationComplete enum value, from which
result of the configuration can be determined;
- The configuration is complete
- One or more mandatory attributes does not have a value
- The configurator was not able to complete the configuration within the given timeout limit
- One or more constraints have been violated
The PCRuntimeSynchronuosConfigurator class exposes
the functionality required by the .NET configurator component to support the
above scenario but it is not yet integrated with any order (sales, production
etc) or product variant creation nor is it integrated with the BOM and Route
KB Article with number 3028719 should be Applied on top of R3 CU 8 as it addresses a stability issue in the solution.
In this example values are passed from the simulated 3rd party configurator into Dynamics AX 2012 through a web service, as illustrated below:
To expose the PCRuntimeSynchronousConfigurator class through
a web service, we start by introducing a new class
PCTechDemoService which implements a method with the SysEntryPointAttribute code attribute, which is
needed for a method to be exposed as a web service.
In this simple implementation the example method looks like this:
public boolean configure(PCName _modelName, str _xmlValues)
PCRuntimeSynchronousConfigurator configurator = PCRuntimeSynchronousConfigurator::construct();
PCProductConfigurationModel productConfigurationModel = PCProductConfigurationModel::findByName(_modelName);
values = '<Assignments>' + _xmlValues + '</Assignments>';
if(configurator.configure(productConfigurationModel.getXML(), values,120000) == Microsoft.Dynamics.Ax.Frameworks.Controls.ProductConfiguration.IsConfigurationComplete::Complete)
ret = true;
Now we can create a Service in the AOT which uses the PCTechDemoService
class and its configure method as an operation. To use this service, it needs
to be put in a service group, which can then be deployed.
To test the service, navigate to System administration > Services and Application Integration Framework > Inbound ports. Here we find our new PCTechDemoServiceGroup, copy the WSDL URI value.
Open Visual Studio Command prompt and type:
Wcftestclient <Your WSDL URI>
This will open the WCF test client where we can now see our web service.
For the demo data set I have used, I will use the following argument values
_modelName : 20001
_xmlValues : <Assignment xPath="powerCableLength" value="10"/><Assignment xPath="videoSystem/television/size" value="42" />
Note: the xPath mechanism used to identify the attributes in model.
If you are familiar with the 20001(Home theater system) model, you will know that it has just two
mandatory attributes which are not assigned by defaults; the powerCableLength
on the root component and the size on the television component.
Attached you will find an Xpp project with code used for the example.