Microsoft Dynamics AX development

Archive for the ‘SSRS Reports’ Category

Textbox hidden: remove horizontal white space

Scenario: I have two textbox on the same line. Textbox A and Textbox B. Both have an hidden expression in order to hide the textbox if empty.


If the Textbox A is empty, maintains the white space in the layout.


The solution is to insert the two textbox in a rectangle.


In this way, the space of the textbox A is removed.


SrsReportDataContractUIBuilder: Enable/disable button depend on a flag

I have to create a dialog with SrsReportDataContractUIBuilder with:

  • a flag “MyFlag”
  • a button “MyButton”

When the flag is active, I have to disable the button.
When the flag is not active, I have to enable the button.

Create the UIBuilder class:

class MyUIBuilderClass extends SrsReportDataContractUIBuilder
    MyClassNameContract       contract;
    FormBuildButtonControl    myButton;
    DialogField               myFlag;

In the postBuild method, initialize the dialog with the controls:

Dialog                  dialogLocal;
Form                    form;
DialogGroup             dialogGroup;
FormBuildGroupControl   groupBuildControl;

dialogLocal = this.dialog();
contract = this.dataContractObject() as MyClassNameContract;
form = this.dialog().form();

myFlag = this.addDialogField(methodStr(MyClassNameContract, parmMyFlag), 

dialogGroup = dialogLocal.addGroup('My group name');
groupBuildControl = dialogLocal.formBuildDesign().control(
buttonBuildControl = groupBuildControl.addControl(FormControlType::Button, 
                     'My button name');


myButton.text(literalStr("A text for my button"));

//if you want to add a method for the button
myButton.registerOverrideMethod(methodStr(FormButtonControl, clicked), 
         methodStr(MyUIBuilderClass, methodForTheButton), this);

myFlag = this.bindInfo().getDialogField(this.dataContractObject(), 
         methodStr(MyClassNameContract, parmMyFlag));
myFlag.registerOverrideMethod(methodStr(FormChecKBoxControl, modified), 
       methodStr(MyUIBuilderClass, enableDisableMyButton), this);



In the method enableDisableMyButton:

public boolean enableDisableMyButton(FormCheckBoxControl _checkBoxControl)
    int ctrlId          = dialog.formRun().controlId('My button name');
    FormControl control = dialog.formRun().control(ctrlId);


    return true;


Insert the logic to bind the UIBuilder to the contract class, in the attributes:


Keep table group on one page

To keep table groups on the same page, the table group should look like this:


Then, select the group row and set the properties “KeepTogheter” to True.


Deploy the report.


Align image logo to the right

1) In the DP class find the width of the image:

Image img = new Image();
CompanyInfo companyInfo = CompanyInfo::find();
CompnayImage companyImage = CompnayImage::findByRecord(comapnyInfo);


salesPackingSlipHeaderTmp.LogoWidth = img.Width();

2) Add the image to the report:


3) Set the parameters to take the image from the dataset:


4) In Visual Studio set the Size property (of the image) to “Original size” (Right click on the image > Properies > Size)

5) Add the following expression in the “padding left” expression:

=CSTR(211-First(Fields!LogoWidth.value, “DataSetName”)) + “pt”

Where 211 is the maximum size (in pixel) of the image.

6) Deploy the report

Print logo depend on print destination

Goal: print the logo only if the print destination is the printer

First of all we need a parameter, and we declare it in the contract class as follow:

public boolean parmPrintLogo(UsePrintMgmt _printLogo = printLogo)
    printLogo = _printLogo;
    return printLogo;

Then, we must to modify the code of the report controller. The controller must extend the SrsPrintMgmtFormLetterController or a subclass of this.

The method to override is: SrsPrintMgmtController.outputReport()
This method executes the report for the print management setting that is currently loaded.

In this way, for every record in the print management, we control the print destination, and consequently we set the parameter for the logo visibility.

protected void outputReport()
    SalesConfirmContract salesConfirmContract = contract as SalesConfirmContract;

    switch (formLetterReport.getCurrentPrintSetting().parmPrintJobSettings().printMediumType())
        case SRSPrintMediumType::Printer : salesConfirmContract.parmPrintLogo(NoYes::No);

        default : salesConfirmContract.parmPrintLogo(NoYes::Yes);


If the logo visibility, depend on the type of the PrintCopyOriginal, the code to use is the following:

protected void outputReport()
    SalesConfirmContract salesConfirmContract = contract as SalesConfirmContract;
    switch (formLetterReport.getCurrentPrintSetting().parmType())
        case PrintMgmtDocInstanceType::Copy :

        case PrintMgmtDocInstanceType::Original :

Now, we have to use the new parameter in the report layout. We found the parameter here:

Finally, insert the following code in the layout, in the “Visibility” property on the image.

Use HTML in SSRS reports

Create a string that contains HTML code, for example:

(TableName).(MyFieldName) = ‘<span style=”font-weight:bold”>’ + custTable.AccountNum + ‘</span>’;

MyFieldName is the name of the field on the tmp table for the report’s  dataset.

Open the layout in Visual Studio. In the report add a textbox and add to the textbox the MyFieldName field.

Right-Click on the placeholder in the textbox, and then click on “Placeholder properties”.


Select “HTML – Interpreter HTML tags as styles


Item description initialization

The field  “Text”, in the Sales order line details, is initialized depend on some parameters.


The parameters to set for the initialization are the following:

Accounts receivable > Setup > Forms > Form setup > General


  1. Include both name and description = Yes: initialize the field with both the name (product name or search name if product name does not exist) and the description inserted in the EcoResProductTranslation
  2. Include both name and description = No: initialize the field only with the description inserted in the EcoResProductTranslation
  3. External item description = Append: merge the content of the field “Text”, with the External item description of the item
  4. External item description = Overwrite: overwrite the content of the field “Text” with the External item description of the item

You can find product name and description here:


And the external item description here:


Tag Cloud