Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

How to reflect report based on Invoice Number

Posted on by 86

Hi Experts,

Requirement is I have to add parameter invoice number and in a open vendor invoices form if a user select N number of invoices and click generate report button   this report will open based on the invoices selected by the user. How can I do that please help. Kindly PFA screenshot.

Regards

2465.ui.png

  • ax.tech Profile Picture
    ax.tech 86 on at
    RE: How to reflect report based on Invoice Number

    Thanks you so much Girish it is working fine now.

  • Verified answer
    GirishS Profile Picture
    GirishS 27,828 Super User on at
    RE: How to reflect report based on Invoice Number

    I have added the code wrongly. It must be helper.parmDatasource(fds);

    You need to pass the FormDataSource object. Also, you have declared buffer for VendTrans table. But your formdataSource is ASL_VTS_ChequeRequisitionSlip. 

     protected void prePromptModifyContract()
        {
            ASL_VTS_ChequeRequisitionSlipReportContract contract = this.parmReportContract().parmRdpContract() as ASL_VTS_ChequeRequisitionSlipReportContract;
            ASL_VTS_ChequeRequisitionSlip chequeRequisitionSlip = this.parmArgs().record() as ASL_VTS_ChequeRequisitionSlip;
            ASL_VTS_ChequeRequisitionSlip vendTrans;
            List list  = new List(Types::String);
            FormDataSource fds = FormDataUtil::getFormDataSource(chequeRequisitionSlip);
            MultiSelectionHelper helper  = MultiSelectionHelper::construct();
         
            helper.parmDatasource(chequeRequisitionSlip);
            vendTrans = helper.getFirst();
    
            while (vendTrans.RecId!=0)
            {
                //inside the loop insert only invoice id to list
                list.addStart(vendTrans.Invoice);
                vendTrans = helper.getNext();
            }
            //now pass the list values to contract class
            contract.parmInvoiceId(list);
        }

    Thanks,

    Girish S.

  • ax.tech Profile Picture
    ax.tech 86 on at
    RE: How to reflect report based on Invoice Number

    Hi Girish,

    Got this error now. Kindly PFA screenshot.

    gbg.png

    Regards

  • Verified answer
    GirishS Profile Picture
    GirishS 27,828 Super User on at
    RE: How to reflect report based on Invoice Number

    MultiSelectionHelper class is in Application common model - So you need to refer that model also.

    Thanks,

    Girish S.

  • ax.tech Profile Picture
    ax.tech 86 on at
    RE: How to reflect report based on Invoice Number

    Hi Girish,

    Thanks for replying. I am getting error in controller class. Kindly PFA contract class, controller class and error screenshot.  

    nh.png

    [
    DataContractAttribute
    //SysOperationGroupAttribute('Date', "@SYS7402", '1')
    ]
    
        class ASL_VTS_ChequeRequisitionSlipReportContract
    {
    
        TransDate       FromDate;
        TransDate       ToDate;
        List            InvoiceId;
    
        //////////////////////////////////////
    
    
        
            [
        DataMemberAttribute('FromDate'),
        SysOperationLabelAttribute('From Date'),
        SysOperationDisplayOrderAttribute('1')
    
        ]
    
    
        public TransDate ParmFromDate(TransDate _FromDate = FromDate)
    
        {
    
            FromDate = _FromDate;
    
            return FromDate;
    
        }
    
        ////////////////////////////////////////////
        [
        DataMemberAttribute('ToDate'),
        SysOperationLabelAttribute('To Date'),
        SysOperationDisplayOrderAttribute('2')
    
        ]
    
        public TransDate ParmToDate(TransDate _toDate=toDate)
    
        {
    
            toDate = _toDate;
    
            return toDate;
    
        }
    
        ////////
        [
        DataMemberAttribute('InvoiceNumber'),
        SysOperationLabelAttribute('Invoice Number'),
        SysOperationDisplayOrderAttribute('3')
    
        ]
    
        public List ParmInvoiceId(List _invoiceId=invoiceId)
    
        {
    
            invoiceId = _invoiceId;
    
            return invoiceId;
    
        }
    
    }
    
    Public class ASL_VTS_ChequeRequisitionSlipController extends SrsReportRunController
    {
        
        
        public void main(Args _args)
        {
            //add your code to call the report along with passing args.
           this.parmArgs(_args);
            
    
        }
    
        protected void prePromptModifyContract()
        {
            ASL_VTS_ChequeRequisitionSlipReportContract contract = this.parmReportContract().parmRdpContract() as ASL_VTS_ChequeRequisitionSlipReportContract;
            ASL_VTS_ChequeRequisitionSlip chequeRequisitionSlip = this.parmArgs().record() as ASL_VTS_ChequeRequisitionSlip;
            VendTrans vendTrans;
            List list  = new List(Types::String);
            FormDataSource fds = FormDataUtil::getFormDataSource(chequeRequisitionSlip);
            MultiSelectionHelper helper  = MultiSelectionHelper::construct();
         
            helper.parmDatasource(chequeRequisitionSlip);
            vendTrans = helper.getFirst();
    
            while (vendTrans.RecId!=0)
            {
                //inside the loop insert only invoice id to list
                list.addStart(vendTrans.Invoice);
                vendTrans = helper.getNext();
            }
            //now pass the list values to contract class
            contract.parmInvoiceId(list);
        }
    
    }

    Regards

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,828 Super User on at
    RE: How to reflect report based on Invoice Number

    Hi ax.tech,

    You need to create a List type parameter in the contract class. Now in the report controller class you need to get the caller record and form datasource. After getting the form datasource you can loop through the selected records using MultiSelectHelperClass and insert into list.

    Add the above logic in prePromptModifyContract method of controller class.

    Controller class.

    Public class YourCOntrollerClassName
    {
        public static void main(Args _args)
        {
            //add your code to call the report along with passing args.
            this.parmArgs(_args);
        }
        
        protected void prePromptModifyContract()
    {
        YourContracClassName contract = this.parmReportContract().parmRdpContract() as YourContracClassName;
        TableName tableName = this.parmArgs().record() as TableName;
        TableName tableName1;
        List list  = new List(Types::String);
         FormDataSource fds = FormDataUtil::getFormDataSource(tableName);
         MultiSelectionHelper helper = MultiSelectionHelper::construct();
        helper.parmDatasource(tableName);
        tableName1 = helper.getFirst();
       
        while (tableName1.RecId != 0)
        {
            //inside the loop insert only invoice id to list
            list.addStart(tableName1.InvoiceId);
            tableName1 = helper.getNext();
        }
         //now pass the list values to contract class
         contract.parmInvoiceIdList(list);     
         }
    }
    }

    In the dp class you can add a range to InvoiceId. Loop through the list using enumerator and add range to it.

    Thanks,

    Girish S.

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... 288,459 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,783 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans