Apr 15, 2013

How to write the customized dialog lookup for SSRS report

Following Sample code is to create customized lookup for dialog field for SSRS report filter. In previous post we used contract class and RDP class , by using this ContractUIBuilder class we can overide the dialog lookup values of Contract class  parmMethods.


class ProfitabilityLookupsUIBuilder extends SrsReportDataContractUIBuilder
{

      DialogField             dialogCategory;
      DialogGroup           dialogGroup;
      boolean                  enable;
} 

//customized lookup method for a field(Category)
private void categoryLookup(FormStringControl _categoryLookup)
{

    Query                                      query = new Query();
    QueryBuildRange                   qbr;
    SysTableLookup                         sysTableLookup;
    // SysReferenceTableLookup     sysRefTableLookup; (For Reference field lookup in AX2012)
    QueryBuildDataSource              qbdsInventTable;
    ;
  
    sysTableLookup = SysTableLookup::newParameters(tablenum(InventTable), _categoryLookup);
   //sysRefTableLookup = SysReferenceTableLookup::newParameters(tablenum(InventTable), _categoryLookup);
  
    qbdsInventTable = query.addDataSource(tableNum(InventTAble)); 
    qbdsInventTable.addRange(fieldNum(InventTable, SupplierCategory).value("");    
    sysTableLookup.addLookupfield(fieldNum(InventTable,SupplierCategory));
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();

} 

public void build()
{
    UBMProductProfitabilityContract     rdpContract =  this.dataContractObject();
 
        dialogCategory = this.addDialogField(methodstr(UBMProductProfitabilityContract,parmcategory),rdpContract);

        dialogCategory.lookupButton(2);

} 

public void postRun()
{
    Dialog dialogLocal = this.dialog();
    DialogField dialogField,dialogField1;
    super(); 

    // This method should be called in order to handle events on dialogs.

    dialogLocal.dialogForm().formRun().controlMethodOverload(false); 

    // Override the methods of category  field. 

    dialogField1 = this.bindInfo().getDialogField(this.dataContractObject(), methodstr(UBMProductProfitabilityContract, parmcategory));

    dialogField1.registerOverrideMethod(methodstr(FormStringControl, lookup), methodstr(ProfitabilityLookupsUIBuilder,  categoryLookup), this);

}

The above class should be used in contract class as following


[DataContractAttribute,
SysOperationContractProcessingAttribute(classstr(ProfitabilityLookupsUIBuilder))
]
class ProfitabilityContract  
{
      SupplierCategory  category;                     
}
Add parmcategory method as shown below
 
[DataMemberAttribute('Category')
]
public AccountNum parmCategory(SupplierCategory _category = category)
{
       category = _ category;
       return category;
} 
------------- After this as usual need to write RDP class  --------------








 

1 comment:

Anonymous said...

Really helpful ... Thanks a lot.