UI Builder Class Not Using the Same Contract as Controller and DP Classes in Dynamics AX 2012

By Taylor Valnes | August 9, 2019

The other day I had to convert a custom query-based SSRS report within Dynamics AX 2012 into a regular report so that we could run the report from a different form (ProdTable & ProdTableListPage) and have certain values auto-populate the query prompt. Normally something like this would be easy to implement, however, I ran into some issues when making the modifications.

I created the data provider, Contract and Controller classes, and the dialog values were not changing. I ended up building a UI Builder class as well to counteract this issue. I had the logic to pre-populate the contract in the controller class by using the record that was highlighted, and I verified that the values were being pulled into the contract class as desired. I then stumbled across the issue of the UI Builder class was not using the same contract instance as the Controller & Data Provider classes. This was resulting in the values not populating the prompt and was not being passed to the Data Provider class. What I wound up having to do is to move my logic into the UI Builder class. Below I have provided the code I created in order to utilize this.

Controller main method:

public static void main(Args _args)
    SSI_DemoController controller = new SSI_DemoController();
    SSI_DemoContract contract = new SSI_DemoContract();

    controller.parmReportName(ssrsReportStr(SSI_DemoReport, Report));


The rest of the logic had to be put into the UI Builder class, specifically the build method.

public void build()
    DialogField dlgItem;
    Args args;
    ProdTable prodTable;
    SRSPrintDestinationSettings printSettings;
    controllerDlg = this.controller();
    contract = this.dataContractObject();
    args = controllerDlg.parmArgs();


    if(args.record() && args.record().TableId == tableNum(ProdTable))
        prodTable = args.record();

    printSettings = controllerDlg.parmReportContract().parmPrintSettings();
    if(contract.parmNumberOfCopies() != 0)

    dlgItem = this.addDialogField(methodStr(SSI_DemoContract,parmItemId),contract);

    dlgItem = this.bindInfo().getDialogField(contract,methodStr(SSI_DemoContract,parmItemId));

This code was able to solve the issue I was having and should help you if you’re facing the same problems. Learn more tips for Dynamics AX 2012 by subscribing to our blog. If you have any questions in the meantime, please reach out to the experts at Stoneridge Software.

Under the terms of this license, you are authorized to share and redistribute the content across various mediums, subject to adherence to the specified conditions: you must provide proper attribution to Stoneridge as the original creator in a manner that does not imply their endorsement of your use, the material is to be utilized solely for non-commercial purposes, and alterations, modifications, or derivative works based on the original material are strictly prohibited.

Responsibility rests with the licensee to ensure that their use of the material does not violate any other rights.

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!