Saturday, December 5, 2009

Product Builder perfomance tip

With the Product Builder modules from Ax, your users (internal or external) can configure their own products. These products can range from electronic devices (demo company) to basically everything you can imagine.

Loading the form for configuration of the product model can take some time. If you have lots of variables (complex product model), it can take more than 20 seconds. And that's an eternity for some users in this day and age.

So I thought to share this little performance tip with you.

In Ax, setting the properties of a form control can take quite some time. The more variables you have, the more form control properties to set. Think of enabled Yes/No, hidden Yes/No.
Now there's no need to set the property, if it's already set. That's a waste of time. So if a field is already hidden, don't hide it again. If it's enabled, don't enable it again.
But unfortunately, that is exactly what the standard code is doing. But we can change this behaviour: Go the the class PBAFrontEndControl, method SetControlProperties.

Change this part:

dataSource.object(valueTmpBuildForm.activeField()).enabled(enabled);
dataSource.object(valueTmpBuildForm.activeField()).mandatory(mandatory);
dataSource.object(valueTmpBuildForm.activeField()).visible(visible);

into this part:

if(dataSource.object(valueTmpBuildForm.activeField()).enabled()!=enabled)
dataSource.object(valueTmpBuildForm.activeField()).enabled(enabled);
if(dataSource.object(valueTmpBuildForm.activeField()).mandatory()!=mandatory)
dataSource.object(valueTmpBuildForm.activeField()).mandatory(mandatory);
if(dataSource.object(valueTmpBuildForm.activeField()).visible()!=visible)
dataSource.object(valueTmpBuildForm.activeField()).visible(visible);

Similar code can be found in the method with the same name in class PBAFrontEndControlWin.

These small modifications reduced the load time of the form to below 5 seconds for us, where it was first 20 seconds +.

Do you have any performance tips as well? Share them in the comments!

3 comments:

  1. Thanks for the tip, one of our customers uses rather large product models and the performance improvement was noticeable.

    ReplyDelete
  2. Hi Florian,

    Glad to be of help.
    There's more room for improvement, especially for product models with many variables. Take a look at the init of the variables (with validation). Drop a comment for more info.

    Regards,
    Willy

    ReplyDelete
  3. This performance tip was very usefull. The form was opening in 22 seconds and now in 4.
    Thanks.

    ReplyDelete