web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Answered

How to get values in from and to date on SSRS report in D365 based on date interval

(0) ShareShare
ReportReport
Posted on by 2,114

Hi Techies,

We are developing a custom SSRS report and we need to print all records between the date interval we are selecting on form. Three parameters we have, Date interval code, From date and To date, Once we select the Date interval code - The from date and to date should populate on 'From date and To date' fields automatically. How to do this?

Date interval code is a master setup where we have start and end date specified already.

I have searched but didn't get much, Can anyone suggest any helpful links on this?

Any response is appreciated.

Thanks!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Agha SirajulDola Profile Picture
    555 on at
  • Verified answer
    Sangram Shinde Profile Picture
    2,114 on at

    Thanks Agha and Sukrut for the helpful links!

    Standard report for LedgerTransStatement(DP, contract and UIBuilder) helped me to write my required logic. Lookup and modified controls are useful.

    Below is the code I have written to achieve this, I have modified it to post here.

    /// <summary>
    /// The <c>SampleUIBuilder</c> class is used to control the report dialog UI for the
    /// <c>Sample_report</c> report.
    /// </summary>
    class SampleUIBuilder extends SrsReportDataContractUIBuilder
    {
        SampleContact 		contract;
        DialogField       	dialogDateInterval,dialogFromDate,dialogToDate,dialogFieldDateCode;
    
        /// <summary>
        /// Override this method in order to initialize the dialog fields after the fields are built.
        /// also to register the dialog field methods to capture events.
        /// </summary>
        public void postBuild()
        {
            super();
            dialogFieldDateCode = this.bindInfo().getDialogField
                (this.dataContractObject(),
                methodStr(SampleContact,parmtimeInterval));
            
            // register override method for lookup
            dialogFieldDateCode.registerOverrideMethod(methodStr(FormStringControl, lookup),
                 methodStr(SampleUIBuilder , lookupDateInterval), this);
    
            dialogFieldDateCode.registerOverrideMethod(methodStr(FormStringControl, modified),
                 methodStr(SampleUIBuilder , dateIntervalModified), this);
           
        }
        /// <summary>
        ///Override build method to add the custom fields
        /// </summary>
        public void build()
        {
            //super();       
            contract = this.dataContractObject();
            dialogFieldDateCode = this.addDialogField(methodStr(SampleContact, parmtimeInterval), contract);
            dialogFromDate      = this.addDialogField(methodStr(SampleContact, parmGetstartdate), contract);
            dialogToDate        = this.addDialogField(methodStr(SampleContact, parmGetenddate), contract);
          
        }
    
        /// <summary>
        /// get the report data contract object
        /// </summary>
        public void initializeFields()
        {
            contract = this.dataContractObject();
        }
    
        public void getFromDialog()
        {
            contract = this.dataContractObject();
            super();
        }
    
        /// <summary>
        /// Lookup method to display date interval lookup as a parameter on form
        /// </summary>
        /// <param name="_control">
        /// The <c>FormStringControl</c> object that adds a lookup field on parameter form
        /// </param>
        public void lookupDateInterval(FormStringControl _control)
        {
            Query  query = new Query();
            QueryBuildDataSource qbds;
            SysTableLookup  sysTableLookup;
           
            sysTableLookup = SysTableLookup::newParameters(tablenum(LedgerPeriodCode),_control);
            sysTablelookup.addLookupfield(fieldNum(LedgerPeriodCode,Code));
            qbds = query.addDataSource(tableNum(LedgerPeriodCode));        
            sysTablelookup.parmQuery(query);        
            sysTablelookup.performFormLookup();        
    
        }
    
        /// <summary>
        /// Updates the start date and end date field based on the selected interval.
        /// </summary>
        /// <param name="_dateCodeDialogControl">
        /// The <c>FormStringControl</c> object that determines the date field values
        /// </param>
        /// <returns>
        /// true if the control value has been modified; otherwise false.
        /// </returns>
        public boolean dateIntervalModified(FormStringControl _dateCodeDialogControl)
        {
            boolean             returnValue;
            LedgerPeriodCode    ledgerPeriodCode;
    
            returnValue = _dateCodeDialogControl.modified();
    
            if (returnValue)
            {
                if (dialogFieldDateCode.value() != '')
                {
                    ledgerPeriodCode = LedgerPeriodCode::find(dialogFieldDateCode.value());
    
                    if (ledgerPeriodCode)
                    {
                        dialogFromDate.value(ledgerPeriodCode.fromDate());
                        dialogToDate.value(ledgerPeriodCode.toDate());
                    }
                }
            }
    
            return returnValue;
        }
    
    }


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans