preloader-matrix

Alfasith

How to add multiple parameter in to SSRS report as Query range in Dynamic AX

Hi,
Adding the fields in the Contract directly reflect on the parameter fields in the report dialog.
Adding the QueryBuildRange and its datasource makes the querying of the ranges value.

CategoryContractClass:
[
    DataContractAttribute,
    SysOperationGroupAttribute(‘Case’, “Case”,’1′),
    SysOperationGroupAttribute(‘Date’, “Date”,’2′),
    SysOperationGroupAttribute(‘PrintOut’, “@SYS12608”, ‘3’)

]
public class CategoryContract implements SysOperationValidatable
{

    FromDate   FromDate;
    ToDate     ToDate;
    CaseCategoryType CaseCategoryType;
    CaseCategory CaseCategory;
}
/******************************************************************/
[
    DataMemberAttribute(‘CaseCategory’),
    SysOperationLabelAttribute(literalstr(“Case Category”)),
    SysOperationHelpTextAttribute(literalstr(“Case Category”)),
    SysOperationGroupMemberAttribute(‘Case’),
    SysOperationDisplayOrderAttribute(‘2’)

]
public CaseCategory parmCaseCategory(CaseCategory _CaseCategory = CaseCategory)
{

    CaseCategory = _CaseCategory;
    return CaseCategory;

}

/******************************************************************/
[
    DataMemberAttribute(‘CaseCategoryType’),
    SysOperationLabelAttribute(literalstr(“Category Type”)),
    SysOperationHelpTextAttribute(literalstr(“Category Type”)),
    SysOperationGroupMemberAttribute(‘Case’),
    SysOperationDisplayOrderAttribute(‘1’)

]
public CaseCategoryType parmCaseCategoryType(CaseCategoryType _CaseCategoryType = CaseCategoryType)
{

    CaseCategoryType = _CaseCategoryType;
    return CaseCategoryType;

}

/******************************************************************/
[
    DataMemberAttribute(‘FromDate’),
    SysOperationLabelAttribute(literalstr(“From Date “)),
    SysOperationHelpTextAttribute(literalstr(“From Date”)),
    SysOperationGroupMemberAttribute(‘Date’),
    SysOperationDisplayOrderAttribute(‘1’)

]
public FromDate parmFromDate(FromDate _FromDate = FromDate)
{

    FromDate = _FromDate;
    return FromDate;

}

/******************************************************************/
[
    DataMemberAttribute(‘ToDate’),
    SysOperationLabelAttribute(literalstr(“To Date”)),
    SysOperationHelpTextAttribute(literalstr(“ToDate”)),
    SysOperationGroupMemberAttribute(‘Date’),
    SysOperationDisplayOrderAttribute(‘2’)

]
public ToDate parmToDate(ToDate _ToDate = ToDate)
{

    ToDate = _ToDate;
    return ToDate;

}

/******************************************************************/
public boolean validate()
{
    boolean             isValid = true;
    if (!CaseCategoryType)
    {
        isValid = checkFailed(“Category Type should be entered”);
    }
     return isValid;
}
/******************************************************************/
CategoryDPClass
[
SRSReportQueryAttribute(queryStr(CategoryQry)),
SRSReportParameterAttribute(classStr(CategoryContract))
]
class CategoryDP extends SRSReportDataProviderBase
{
    CategoryTmp  CategoryTmp;
    CaseCategory CaseCategory;
    CaseCategoryType CaseCategoryType;
    FromDate FromDate;
    ToDate ToDate;
}
/******************************************************************/
private Query buildQuery( Query             _query,
                          CaseCategoryType  _CaseCategoryType,
                          CaseCategory      _CaseCategory,
                          FromDate          _FromDate,
                          ToDate            _ToDate)
    {

        if(_CaseCategoryType)
            _query.dataSourceTable(tablenum(CaseCategoryHierarchyDetail),1).addRange(fieldnum
(CaseCategoryHierarchyDetail, CategoryType)).value(queryValue(_CaseCategoryType));

       if(_CaseCategory)
           _query.dataSourceTable(tablenum(CaseCategoryHierarchyDetail),1).addRange(fieldnum
(CaseCategoryHierarchyDetail, CaseCategory)).value(queryValue(_CaseCategory));

        if(_FromDate && _ToDate)
          _query.dataSourceTable(tablenum(CaseDetailBase),1).addRange(fieldnum
(CaseDetailBase, CreatedDateTime)).value(queryRange(_FromDate,_ToDate));

        return _query;

     }

/******************************************************************/
[
SRSReportDataSetAttribute(tableStr(CategoryTmp))
]
public CategoryTmp getCategoryTmp()
{

    select * from CategoryTmp;
    return CategoryTmp;

}

/******************************************************************/
private void getReportParameters()
{

    CategoryContract CategoryContract = this.parmDataContract();
    if (CategoryContract)
     {

         CaseCategoryType     = CategoryContract.parmCaseCategoryType();
         CaseCategory         = CategoryContract.parmCaseCategory();
         FromDate             = CategoryContract.parmFromDate();
         ToDate               = CategoryContract.parmToDate();

     }

 }

/******************************************************************/
public void InsertCategoryTmp(CaseDetailBase _CaseDetailBase,CaseCategoryHierarchyDetail _CaseCategoryHierarchyDetail)
{
    HcmWorker HcmWorker;
    DirPartyTable DirPartyTable;
    CaseDetailBase CaseDetailBase;
    CategoryTmp.CaseId      = _CaseDetailBase.CaseId;
    CategoryTmp.Logo        = CompanyImage::findByRecord(CompanyInfo::find()).Image;
   // CaseCategoryTmp.Name        = _CaseDetailBase.displayOwnerName();
    CategoryTmp.Status      = _CaseDetailBase.Status;
    CategoryTmp.Description = _CaseDetailBase.Description;
    CategoryTmp.Priority    = _CaseDetailBase.Priority;
   // CaseCategoryTmp.OwnerWorker = _CaseDetailBase.OwnerWorker;
    select DirPartyTable join HcmWorker join CaseDetailBase where DirPartyTable.RecId == HcmWorker.Person
                          && CaseDetailBase.CaseId == _CaseDetailBase.CaseId
                          && CaseDetailBase.OwnerWorker == HcmWorker.RecId;
    CategoryTmp.Name = DirPartyTable.Name;

    CategoryTmp.DateTime    = _CaseDetailBase.createdDateTime;
    CategoryTmp.CategoryType = _CaseCategoryHierarchyDetail.CategoryType;
    CategoryTmp.CaseCategory = _CaseCategoryHierarchyDetail.CaseCategory;
    CategoryTmp.insert();

}

/******************************************************************/
[SysEntryPointAttribute(false)]
public void processReport()
{

    CaseDetailBase              CaseDetailBase;
    CaseCategoryHierarchyDetail CaseCategoryHierarchyDetail;
     QueryRun queryrun;
    ;
    this.getReportParameters();
    queryRun = new QueryRun(this.buildQuery(this.parmQuery(),CaseCategoryType,CaseCategory,
FromDate,ToDate));
    //queryRun = new QueryRun(this.parmQuery());
    while(queryRun.next())
    {
         CaseDetailBase                   =queryrun.get(tableNum(CaseDetailBase));
         CaseCategoryHierarchyDetail      =queryrun.get(tableNum(CaseCategoryHierarchyDetail));
        this.InsertCategoryTmp(CaseDetailBase , CaseCategoryHierarchyDetail);
    }
}

/******************************************************************/
Share on email
Share on facebook
Share on twitter
Share on linkedin
Share on pinterest

Leave a Reply

Your email address will not be published.