Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / How to add report Para...
Finance forum
Unanswered

How to add report Parameter in RDL report then make the report run by read the parameters ?

Posted on by 159
Hi,
 
When we have RDL report, how to add parameter in the UI (dialog) of the report ? 
Are we using contract class as well, like below :
 
[
    SrsReportNameAttribute('MY_TaxTrans.Report')
]
public class MY_TaxTransContract extends SrsReportRdlDataContract
{
    TransDate       fromDate, toDate;
    [DataMemberAttribute('FromDate'),
        SysOperationLabelAttribute(literalStr("FromDate"))
    ]
        public TransDate parmFromDate(TransDate _fromDate = fromDate)
    {
        fromDate = _fromDate;
        return fromDate;
    }
    [DataMemberAttribute('ToDate'),        
        SysOperationLabelAttribute(literalStr("ToDate"))
    ]
    public TransDate parmToDate(TransDate _toDate = toDate)
    {
        toDate = _toDate;
        return toDate;
    }
}
 
Or there is other way ? 
 
The one I created is Tax report, TaxTrans, so here I already did duplicate the report itu "MY_TaxTrans". Initially, it does not prompt Date when we run it, so I want to add it in the UI (noted that actually we can just input in the query (Record to include).
 
Thanks
 
  • Martin Dráb Profile Picture
    Martin Dráb 225,490 Super User on at
    How to add report Parameter in RDL report then make the report run by read the parameters ?
    The question whether it's an RDL report or an RDP report isn't a good one. Report Definition Language (RDL) is the language defining SSRS reports and therefore it's used by all reports. You likely meant whether the report takes data from a report data provider (RDP) class or a query, but you already know the answer (your screenshot shows that Data Source Type = Report Data Provider).
     
    TaxTransDetailRdlContract is just a normal data contract used by the RDP class. It is decorated with the DataContract attribute. I don't think you should be using TaxTransRdlContract class for your purpose.
     
    Your UI builder class doesn't seem to be needed, because it doesn't contain any logic that the automatic UI builder can't do for you.
  • CU28051221-0 Profile Picture
    CU28051221-0 159 on at
    How to add report Parameter in RDL report then make the report run by read the parameters ?
    Hi,
     
    Based on the report source, I can say it is RDP. Although I still don't know why the original classes, using RdlContract.
    So, anyway it is still confusing to me to understand this.
    Thanks
  • CU28051221-0 Profile Picture
    CU28051221-0 159 on at
    How to add report Parameter in RDL report then make the report run by read the parameters ?
    Hi,
     
    Anyone out here can help to clarify this ? 
    It's become frustrating for what it seems to be simple thing turns out to be complicated and take much time.
    Again, I know we can put the date range filtering in the "Record to include" section, the query it self.
     
    Thanks.
  • CU28051221-0 Profile Picture
    CU28051221-0 159 on at
    How to add report Parameter in RDL report then make the report run by read the parameters ?
    Hi,
     
    Back to my original intention to duplicate Tax transactions report, and added From Date and To Date parameters in its Dialog.
     
    Currently it is more confusing to me, the main question is, is this report an RDP report or RDL report ? since if I take a look at the Dataset of the report, it is from TaxTransDP, which mean it is RDP report ->
     
     
     
    May I explain from the start, the trace result that I did all this time:
     
    1. This is the menu ->
        

        
     
    2.  By looking at the menu Output property, this is call controller class "taxTransController"
         
     
    3.  But if we take a look at "taxTransController", the method is calling contract class RdlContract ->
         
     
     
    And because in that "TaxTransRdlContract", there is no Parameter FromDate and ToDate, I believe it is correct, since the dialog is without it. But since I want to add it, I'm looking at some other class which is found an RdlContract which "looks like" it has FromDate and ToDate" -> CustCollLetterOverviewRdlContract
     
    But as the result as of now, the dialog still with no dates parameters as per my intention.
     
    Anyone can help for me to have clear understanding about this ?
     
    Much appreciated.
    Thanks.
  • CU28051221-0 Profile Picture
    CU28051221-0 159 on at
    How to add report Parameter in RDL report then make the report run by read the parameters ?
    Hi Layan,
     
    Actually I'm following this sample objects -> CustCollLetterOverviewRdlContract
     
    Over there, there is also no [DataContractAttribute]
     
    and since this is RDL. as per my understanding we don't use RDP class, am I right to say that ?


    Thanks
  • Layan Jwei Profile Picture
    Layan Jwei 4,723 Super User on at
    How to add report Parameter in RDL report then make the report run by read the parameters ?
    Hi,

    In general to see contract parameters, then your contract class should have a data contract attribute
     
    [DataContractAttribute]
    class TestContract
    {
    }

    And your RDP class should have the contract defined
    [SRSReportParameterAttribute(classStr(TestContract))]
    class TestRDP extends SRSReportDataProviderBase
    {
    }

    Thanks,
    Layan Jweihan
  • CU28051221-0 Profile Picture
    CU28051221-0 159 on at
    How to add report Parameter in RDL report then make the report run by read the parameters ?
    Hi,
     
    I have changed my Contract class. However, still need some advice whether I'm doing it correctly. So, my intention is to duplicate Report from menu Tax > Inquiry & Reports > Tax Reports > Tax transactions.
     
    Here what I did so far:
     
    1. Duplicate report TaxTrans, say to MY_TaxTransRpt
    2. Create new contract class as below:
    [
        SrsReportNameAttribute(ssrsReportStr(MY_TaxTransRpt, Report)),
        SysOperationContractProcessingAttribute(classStr(MY_TaxTransUIBuilder), SysOperationDataContractProcessingMode::CreateUIBuilderForRootContractOnly)
        ]
    public class MY_TaxTransContract extends SrsReportRdlDataContract implements SysOperationValidatable
    {
         
        public const str ParameterNameFromDate = 'FromDate';
        public const str ParameterNameToDate = 'ToDate';
    
        public FromDate parmFromDate(FromDate _fromDate = DateTimeUtil::date(this.getValue(ParameterNameFromDate)))
        {
            this.setValue(ParameterNameFromDate, DateTimeUtil::newDateTime(_fromDate, 0));
            return _fromDate;
        }
    
        public ToDate parmToDate(ToDate _toDate = DateTimeUtil::date(this.getValue(ParameterNameToDate)))
        {
            this.setValue(ParameterNameToDate, DateTimeUtil::newDateTime(_toDate, 0));
            return _toDate;
        }
    
        public boolean validate()
        {
            boolean isValid = true;
            var fromDate = this.parmFromDate();
            var toDate = this.parmToDate();
    
            if ((fromDate && !toDate) ||
                (!fromDate && toDate))
            {
                checkFailed("@SYS24455");
                isValid = false;
            }
            else if (fromDate > toDate)
            {
                checkFailed("@SYS22806");
                isValid = false;
            }
    
            return isValid;
        }
    
    }
    
     
    3.  Create new class for UIBuilder
     
    class MY_TaxTransUIBuilder extends SrsReportDataContractUIBuilder
    {
        private DialogField fromDateField;
        private DialogField toDateField;
    
        private MY_TaxTransContract contract;
    
        public void build()
        {
            #Characters
    
            Dialog dialogLocal = this.dialog();
            contract = this.dataContractObject() as MY_TaxTransContract;
    
            fromDateField = dialogLocal.addFieldValue(extendedTypeStr(FromDate), contract.parmFromDate());
            toDateField = dialogLocal.addFieldValue(extendedTypeStr(ToDate), contract.parmToDate());
        }
    
        /// <summary>
        /// Passes user input to a report data contract class.
        /// </summary>
        public void getFromDialog()
        {
            contract.parmFromDate(fromDateField.value());
            contract.parmToDate(toDateField.value());
        }
    
    }
    
    4. Create new class for controller
     
    
    public class MY_TaxTransController extends SrsReportRunController
    {
        protected void preRunModifyContract()
        {
            var contract = this.parmReportContract().parmRdlContract() as MY_TaxTransContract;
            var query = this.getFirstQuery();
    
            SrsReportHelper::addFromAndToDateRangeToQuery(query,
                                                          contract.parmFromDate(),
                                                          contract.parmToDate(),
                                                          tableNum(TaxTrans),
                                                          fieldNum(TaxTrans, TransDate));                
        }
    
        public static void main(Args _args)
        {
            MY_TaxTransController controller = new MY_TaxTransController();
            controller.parmReportName(ssrsReportStr(MY_TaxTransRpt, Report));
            controller.parmArgs(_args);
            controller.startOperation();
        }
    }
    
     
    5.  New menuitemOutput
    Setting in navigation panel is like this:
     
     
     
     
    Only DP class I haven't create, so expected to not filter anything first and keep using the original.. However after Build and synchronize everything, 
    I'm still cannot see the FromDate and ToDate in dialog.
     
    May I know what I missed.
     
    Thanks.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans