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)

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

I have the same question (0)
  • Suggested answer
    Zain Bokhari Profile Picture
    3,208 Moderator on at

    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.

  • Mohammed Altaf Profile Picture
    435 on at

    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

    [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

    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.

  • Zain Bokhari Profile Picture
    3,208 Moderator on at

    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);

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
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans