Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

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.

  • Zain Bokhari Profile Picture
    Zain Bokhari 3,206 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,206 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,206 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.

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... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans