In this blog post we will describe how you can set valuesbased on the current user ID by leveraging system-defined table constraintstogether with the build-in query range methods.
If you are familiar with the Product Builder configurator,you may by familiar with the User Profilefeature where you can associate a collection of default values with a givenuser. Use the following description to achieve a similar behavior using theProduct Configurator.
The table we create for this example should look like this and have two columns, that is, one forthe User ID (uses the UserID EDT) and one for our user-specific value (an Integer to keep it simple).
Once the table is created, we can add the user specific data.
As seen above, we have added the value 42 for the Adminuser ID. The intention is that when the table constraint is created and used inmodel, the attribute, which will be bound to the UserSpecificIntegerValuecolumn, will be assigned the value that corresponds to the current user ID.
Now that the System Table is created, we can create the actual table constraint. This is done byopening the Table constraint definitionform, under Product information management -> Common -> Product configuration models.
Create a new table constraint by clicking the new button.
Select System defined, and enter the name of the table created previously.
Add a column for the user-specific integer value and choose an integer attribute type with ranges.
Now comes the part which gives the attribute a user-specific value. This can be accomplished byopening the Select query (SysQuery) form and entering the range specifiedbelow. The content of the table will be filtered to just return the recordsassociated with the current user ID.
Click OK to complete the table constraint creation, click Next in the Wizard, and then click OK again.
Having just created our system-defined table constraint, we are now ready to use it in a Productconfiguration model. Below I have create a very simple model with 3 attributes:
Similarly, I have added an attribute named "Only Dmitry", which only will bevisible if the user log on to Dynamics AX is associated with User ID Dmitry.
Once the attributes have been defined, it's time to attach the table constraint to themodel. This is done by creating a new constraint in the constraints section andselecting Table constraint in the opened dialog.
Then select the new table constraint and associate the user-specific value attribute withthe user-specific value column, as shown below.
We are now ready to launch the model we created with the attached table constraint. As can be seenbelow, once the model is loaded, the User Specific Value is assigned the value 42 by the configurator. The "OnlyAdmin" attribute is shown and the"Only Dmitry" attribute is hidden.
This example can be extended to include several other concepts like hiding subcomponents andgrouping user specific value into table constraints. An obvious use case wouldbe that you hide some parts of the Product configuration model from the ordertakers (Susan persona). This could be engineering-specific details and theproduct designer (Emil persona) would still be able to see them.
Furthermore, the above pattern can be used together with other of the build-in query rangemethods.
It you are runningon a build that has a performance fix to run the XML generation in IL, you willneed to generate IL for the SysQueryRangeUtil class.
I hope you find this useful