UI Builder Class to Develop SSRS Reports in Microsoft Dynamics AX 2012
UI Builder Class Overview
User Interface
(UI) Builder Class is used to define the layout of the parameter dialog box
that opens before a report is run in Microsoft Dynamics AX. It is used to add
the customizations as well as additional fields in the dialog.
Following
are the scenarios where UI Builder Class can be used:
- Grouping dialog fields
- Overriding dialog field events
- Adding a customized lookup to a dialog field
- Binding dialog fields with Report contract parameters
- Changing the layout of the dialog
- Adding custom controls to the dialog
To create
a UI builder class, extend it with SrsReportDataContractUIBuilder.
Pre-requisites
- Microsoft Dynamics AX 2012
- Reporting services extensions must be installed in Dynamics AX
- Report contract class
Sample UI Builder Class
- Create a new class. Open AOT à Classes
- Right Click on Classes and select New Class. Name it as SSRSDemoUIBuilder
- Open the Class declaration by right clicking on it and selecting View code
- Write the following code
1
2
3
4
|
public
class SSRSDemoUIBuilder extends SrsReportDataContractUIBuilder
{
}
|
- Now open the contract class and add the following line to the header of the class. It will tell the contract class to build the parameter dialog. In other words, it will link the UI Builder Class with the contract class.
1
|
SysOperationContractProcessingAttribute(classStr(SSRSDemoUIBuilder))
|
Examples of UI Builder Class Usage
Based on
different scenarios, different methods are overridden as shown in the following
examples:
- Grouping the dialog fields/Changing the layout of the dialog/Adding custom controls to the dialog
- To customize the layout and add custom fields, override the build as shown below:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
public
void build()
{
DialogGroup
dlgGrp;
//get
the current dialog
Dialog dlg
= this.dialog();
//make
required modifications to the dialog
dlgGrp
= dlg.addGroup('Dates');
dlgGrp.columns(2);
dlg.addField(identifierStr(FromDate));
dlg.addField(identifierStr(ToDate));
dlgGrp
= dlg.addGroup('Customer');
dlg.addField(identifierStr(CustAccount));
}
|
- ThIS build method is called by the report framework to generate the layout of the dialog.
- Binding dialog fields with Report contract parameters
- Write the following code in the build method:
1
2
3
4
5
|
//get
the report data contract object
contract
= this.dataContractObject();
//associate
dialog field with data contract method
this.addDialogField(methodStr(SSRSDemoContract,parmCustGroupId),
contract);
|
- Overriding dialog field events/Adding a customized lookup to a dialog field
- To add a customized lookup or to override a control method, create a new method containing the business logic. The new method must have the same signature as the method you want to override.
- Then, override the postBuild method and register the method to override with the new method created.
- In the following example, the lookup method of a field is to be overridden. To do this, create a new method lookupCustGroup and add the following code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
public
void lookupCustGroup(FormStringControl _formStringControl)
{
Query
query = new Query();
QueryBuildDataSource
DS;
SysTableLookup
sysTablelookup;
//create
a table lookup
sysTablelookup.addLookupfield(fieldNum(CustGroup,CustGroup));
sysTablelookup.addLookupfield(fieldNum(CustGroup,Name));
//create
a query
DS
= query.addDataSource(tableNum(CustGroup));
DS.addRange(fieldNum(CustGroup,PaymTermId)).value('N030');
//assign
the query and call lookup
sysTablelookup.parmQuery(query);
sysTablelookup.performFormLookup();
}
|
- Now, override the postBuild method and write the following code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
public
void postBuild()
{
DialogField
dlgCustGroup;
super();
//get
the field to override by providing the data contract object and the
associated attribute/method
dlgCustGroup
= this.bindInfo().getDialogField(this.dataContractObject(),
methodStr(SSRSDemoContract,parmCustGroupId));
//register
the method we want to override
dlgCustGroup.registerOverrideMethod(
methodStr(FormStringControl,
lookup),
methodStr(SSRSDemoUIBuilder,lookupCustGroup),
this);
}
|
- bindInfo returns an object of type SysOperationUIBindInfo. It contains information about the dialog controls bounded to a report contract.
- postBuild method is called when dialog is created.
No comments:
Post a Comment