Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to Pass a Parameter in Report Data Provider Class

(0) ShareShare
ReportReport
Posted on by 435

Hi there,

             I have Created a Report Data Provider class which retrieves information of PO invoices.

I have added one button in VendInvoiceJournal Form and i wrote some code in button clicked method.

The Report is Working fine when i pass the PurchID Value in Query in processReport method of my DataProvider Class, but i need to run this report by taking the parameter (i.e; PurchID or RecID) from VendInvoiceJournal  form.

 Can you please suggest me how to pass the parameter from VendInvoiceJournal Form to my Report.

Thanks.

Regards.

*This post is locked for comments

  • Zain Bokhari Profile Picture
    3,208 Moderator on at
    RE: How to Pass a Parameter in Report Data Provider Class

    You can only send string values through args.parm("TextValue"); If you need to pass a recID or record you need to do the following.

    On the click method where you are calling your report, pass the record like this:

    args.record(TableName); // before calling the report

    in the prePromptModifyMethod of your controller class. Receive it like this.

    TableName tableObject = this.parmArgs().record();

    contract.parmRecordId(tableObject.RecId);

  • Mohammed Altaf Profile Picture
    435 on at
    RE: How to Pass a Parameter in Report Data Provider Class

    Hi Zain,

      As you said i made the changes in the class, now the report is getting showed but no data is getting populated.

    Thanks

    Regards.

  • Suggested answer
    Zain Bokhari Profile Picture
    3,208 Moderator on at
    RE: How to Pass a Parameter in Report Data Provider Class

    [DataMemberAttribute('RecordId')]
    public recId parmRecordId(recId _recordId = recordId)
    {
    recId ret;
    ret = super(_recordId);
    return ret;
    }


    Take a look at this part, this is not correct.
    it should be like this:

    [DataMemberAttribute('RecordId')]
    public recId parmRecordId(recId _recordId = recordId)
    {

    recordId = _recordId;
    return recordId;

    }
    and Class Declaration of contract class should have the recordID declared like this:
    RecID  recordId;

    Make these changes, refresh cache, run incremental CIL, refresh your report and re-deploy it.

  • Mohammed Altaf Profile Picture
    435 on at
    RE: How to Pass a Parameter in Report Data Provider Class

    Hi Zain thanks for the reply.

    i am following this approach

    i have created two classes

    First DataContract Class which has Class Declaration and ParmRecordId methods.

    Code for ParmRecordId :-

           [DataMemberAttribute('RecordId')]

           public recId parmRecordId(recId _recordId = recordId)

           {

                recId ret;

                ret = super(_recordId);

               return ret;

          }

    Second Dataprovider Class which has Class Declaration,getDataTmp and processReport method.

    Code For processReport  :-

    public void processReport()

    {

       om_CostOfGoodsContract contract       =    this.parmDataContract() as om_CostOfGoodsContract;

       RecId    recId =    contract.parmRecordId();

       VendInvoiceTrans vendInvoiceTrans;

       VendInvoiceJour  vendInvoiceJour;

       goodsCostingTmp     localgoodsCostingTmp;

       RecordSortedList       recordList;

       localgoodsCostingTmp  = goodsCostingTmp::findRecId(recId);

       while select vendInvoiceTrans join vendInvoiceJour

       where vendInvoiceTrans.RecId ==  recId &&

                  // vendInvoiceTrans.PurchID == 'PO-002286' &&

       vendInvoiceTrans.InvoiceId == vendInvoiceJour.InvoiceId

       {

            //clear the temporary table

           goodsCostingTmp.clear();

           //records from vendinvoicetrans

           goodsCostingTmp.InvoiceId      = vendInvoiceJour.InvoiceId;

           goodsCostingTmp.InvoiceAccount = vendInvoiceJour.InvoiceAccount;

           goodsCostingTmp.InvoiceAmount  = vendInvoiceJour.InvoiceAmount;

           goodsCostingTmp.InvoiceAmountMST = vendInvoiceJour.InvoiceAmountMST;

           // records from vendInvoiceTrans

           goodsCostingTmp.PurchID       = vendInvoiceTrans.PurchID;

           goodsCostingTmp.Name           = vendInvoiceTrans.Name;

           goodsCostingTmp.ItemId          = vendInvoiceTrans.ItemId;

           goodsCostingTmp.LineAmount = vendInvoiceTrans.LineAmount;

           goodsCostingTmp.LineAmountMST = vendInvoiceTrans.LineAmountMST;

           goodsCostingTmp.CurrencyCode  = vendInvoiceTrans.CurrencyCode;

           goodsCostingTmp.DeliveryName  = vendInvoiceTrans.DeliveryName;

           goodsCostingTmp.InternalInvoiceId = vendInvoiceTrans.InternalInvoiceId;

           goodsCostingTmp.InvoiceDate   = vendInvoiceTrans.InvoiceDate;

           goodsCostingTmp.OrigPurchId   = vendInvoiceTrans.OrigPurchId;

           goodsCostingTmp.PriceUnit     = vendInvoiceTrans.PriceUnit;

           goodsCostingTmp.Qty           = vendInvoiceTrans.Qty;

           //insert data

           goodsCostingTmp.insert();

       }  

    }

    I tried to Debug the Code the DataContract  Class is reading RecID but i am facing error while reading the RecId in ProcessReport Method.

    Thanks.

    Regards.

  • Suggested answer
    Zain Bokhari Profile Picture
    3,208 Moderator on at
    RE: How to Pass a Parameter in Report Data Provider Class

    in your code where you call the report. you can just send the PurchID or whatever value through args.parm(value) and receive it in the controller class preRunModifyContract() method.

    Create a new hidden parameter for PurchID and pass the value received above to the contract class which you can then receive in the RDP class.

    Feel free to ask if you have any further confusions.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 48

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans