Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

How to Pass a Parameter in Report Data Provider Class

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
    Zain Bokhari 3,208 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
    Mohammed Altaf 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
    Zain Bokhari 3,208 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
    Mohammed Altaf 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
    Zain Bokhari 3,208 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans