Showing posts with label Lookup Field using UIBuilder in SSRS report in ax 2012. Show all posts
Showing posts with label Lookup Field using UIBuilder in SSRS report in ax 2012. Show all posts

Friday, 20 April 2018



Lookup Field using UIBuilder in SSRS report in ax 2012




Client want to see the report color wise but in report there is only item wise.
So I have  added color in selection which must be lookup





Then add one parameter to existing contract class


[
DataMemberAttribute("EcoResColorName"),
SysOperationDisplayOrderAttribute("4")

]


public EcoResColorName parmInventColorId(EcoResColorName _inventColorId = inventColorId)
{
    inventColorId = _inventColorId;

    return inventColorId;
}


For that I create UI builder class

name the class and extends SrsReportDataContractUIBuilder

public class Aks_SRCustomLookupsUIBuilder extends SrsReportDataContractUIBuilder
{

     BOMRDPContract    BOMRDPContract;
     ItemId  itemId;


}


public void build()
{
    int i;

    BOMRDPContract = this.dataContractObject();// as BOMRDPContract;
    this.addDialogField(methodStr(BOMRDPContract, paramItemId),BOMRDPContract);
    this.addDialogField(methodStr(BOMRDPContract, paramKgs),BOMRDPContract);
    this.addDialogField(methodStr(BOMRDPContract, paramQty),BOMRDPContract);

    this.addDialogField(methodStr(BOMRDPContract, parmInventColorId),BOMRDPContract);
}

public void postBuild()
{
     DialogField dlgBomid;
     DialogField dlgColorid;

    super();


    dlgColorid = this.bindInfo().getDialogField(this.dataContractObject(),methodStr(BOMRDPContract,parmInventColorId));

    dlgColorid.registerOverrideMethod(methodStr(FormStringControl, lookup),methodStr(GOD_SRCustomLookupsUIBuilder, BomIdLookUp),this);


}

private void BomIdLookUp(FormStringControl  _formStringControl)
{
    Query query = new Query();
    QueryBuildDataSource DS;
    SysTableLookup sysTablelookup;
    QueryBuildDataSource    queryBuildDataSourceLocal,queryBuildDataSourceLocal1,queryBuildDataSourceLocal2;
    //aks
    InventDimCombination inventDimCombination;
    InventDim                     inventDim;
    //aks

    //create a table lookup

   /* DS = query.addDataSource(tableNum(EcoResColor));
    sysTablelookup = SysTableLookup::newParameters(tableNum(EcoResColor), _formStringControl);
    sysTablelookup.addLookupfield(fieldNum(EcoResColor,Name));*/




    sysTablelookup = SysTableLookup::newParameters(tableNum(inventDim), _formStringControl);
    sysTablelookup.addLookupfield(fieldNum(inventDim,InventColorId));

    DS = query.addDataSource(tableNum(inventDim));
    DS = DS.addDataSource(inventDimCombination);

    DS.addLink(fieldNum(inventDim, InventDimId),fieldNum(inventDimCombination,InventDimId));

    DS.addRange(fieldNum(inventDimCombination,ItemId)).value(BOMRDPContract.paramItemId());
    //"1120132");

    //assign the query and call lookup
    sysTablelookup.parmQuery(query);
    sysTablelookup.performFormLookup();




}





Thanks
Akshay