Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

get Parameter from Contract class to DP class

Posted on by 380

Evening,

I`ve been struggling with a problem. I need to launch a SSRS report from a form. For this reason I`m using a Controller class, a Data Contract class and a Data Provider Class. Controller class simply gets Args from caller and sets parameters in Data Contract class. That works fine. The tricky part is that I cant get the parameter from Data Contract to Data provider class. Inside the Data Provider class I have an object of the Data Contract, but when I try to get the parameter, it returns me an empty value.

I present you the code snippets, so that the view could be clearer.

Controller class:

class SalesPackageListController extends SrsReportRunController
{
}

public static client void main(Args args)
{
    SalesPackageListController controller = new SalesPackageListController();

    controller.parmReportName(ssrsReportStr(PackageListReport, PackageListLT));
    controller.parmArgs(args);
    controller.startOperation();
}

protected void prePromptModifyContract()
{
    CustPackingSlipJour                         CustPackingSlipJour;
    SalesPackageListDataContract                contract;
    ;

    CustPackingSlipJour = this.parmArgs().record();
    contract = this.parmReportContract().parmRdpContract() as SalesPackageListDataContract;
    contract.parmSalesId(CustPackingSlipJour.SalesId);
}


Data Contract class:

[DataContractAttribute]
public class SalesPackageListDataContract
{
    SalesId                 SalesId;
}

[DataMemberAttribute("SalesId")]
public SalesId parmSalesId(SalesId _salesId = SalesId)
{
    ;

    SalesId = _salesId;
    return SalesId;
}


Data Provider class:

[SRSReportParameterAttribute(classstr(SalesPackageListDataContract))]
public class SalesPackageListDP extends SRSReportDataProviderBase
{
    SalesPackageListHeaderFooterTmp                     SalesPackageListHeaderFooterTmp;
    SalesPackageListDetailsTmp                          SalesPackageListDetailsTmp;
}

public void processReport()
{
    SalesPackageListDataContract     SalesPackageListDataContract;
    CustPackingSlipTrans             CustPackingSlipTrans;
    SalesId                          salesId;
    ;
    
    SalesPackageListDataContract = this.parmDataContract();
    salesId = SalesPackageListDataContract.parmSalesId();    
        
    while select * from CustPackingSlipTrans
    where CustPackingSlipTrans.SalesId == salesId
    {
        SalesPackageListDetailsTmp.clear();
        SalesPackageListDetailsTmp.SalesId = CustPackingSlipTrans.SalesId;
        SalesPackageListDetailsTmp.ItemId = CustPackingSlipTrans.ItemId;
        SalesPackageListDetailsTmp.insert();
    }        
}


So, I cant get the salesId variable in Data Provider`s method processReport. Any suggestions what could be wrong?


*This post is locked for comments

  • Suggested answer
    Khurshid Wali Profile Picture
    Khurshid Wali 922 on at
    RE: get Parameter from Contract class to DP class

    I faced a similar issue which was resolved after restarting the AOS Service. :)

  • jeluzardo Profile Picture
    jeluzardo 2 on at
    RE: get Parameter from Contract class to DP class

    That solved my problem too, just do a refresh of the datasets in the report and redeploy it.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: get Parameter from Contract class to DP class

    Unable to run ssrs report with parameters in batch mode execution AX 2012 R3.  I tried specifying the parameters but no go:

    // Explicitly provide all required parameters
    rdpContract.parmReportStateDate(systemDateGet());
    controller.parmReportContract().parmRdpContract(rdpContract);

    Need help to run ssrs report with parameters in batch mode ax 2012 r3!

  • Nayyar Siddiqi Profile Picture
    Nayyar Siddiqi 257 on at
    RE: get Parameter from Contract class to DP class

    Came across with the exact issue, in the end got it resolved by refreshing the datasets of report deployed it again and restarting AX client similar to what Asim Saeed suggested.

  • Shima.Y Profile Picture
    Shima.Y 50 on at
    RE: get Parameter from Contract class to DP class

    I have the same problem 

    I checked all of thing many times, but everything look normal, I've read all of replies but non of them solved my problem ...

    Would you please help me ?

  • Asim Saeed Profile Picture
    Asim Saeed 575 on at
    RE: get Parameter from Contract class to DP class

    Hi,

    Recently i also had faced similiar issue, that legerJournalId contract parm was not showing up in 'processreport' method, even though journalId was shwoing in controller class.

    //CONTROLLER CLASS

    protected void preRunModifyContract()

    {

       ASM_VendBankPayChequeContract   vendBankPayChequeContract;

       vendBankPayChequeContract = this.parmReportContract().parmRdpContract() as ASM_VendBankPayChequeContract;

       ledgerJournalId = this.parmArgs().parm();

       vendBankPayChequeContract.parmLedgerJournalId(ledgerJournalId);

    }

    //REPORT DATA PROVIDER CLASS

    public void processReport()

    {

       LedgerJournalId                 ledgerJournalId;

       LedgerJournalTrans              ledgerJournalTrans;

       ASM_VendBankPayChequeContract   vendBankPayChequeContract;

       breakpoint;

       vendBankPayChequeContract = this.parmDataContract() as ASM_VendBankPayChequeContract;

       ledgerJournalId = vendBankPayChequeContract.parmLedgerJournalId();

    Resoultion:

    What i did, is refresh the dataset in report design and re-deployed the report. I worked perfectly fine

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: get Parameter from Contract class to DP class

    Other several helpful things:

    1. You cannot send tables to data provider (common type)  - just use tableid to retrieve the data, and you must use DataMemberAttribute, otherwise Data provider won't get the data you set in contract.

    2. Data provider use the CIL, so whether there are related changes - must compile CIL.

    3. Sometimes there is cache, and you shall: restart the SSRS service, clear AUC file, do cache refresh (from tool menu).

    Thanks, anyway :)

  • Mohammad Raziq Ali Profile Picture
    Mohammad Raziq Ali 2,432 on at
    RE: get Parameter from Contract class to DP class

    Hi Eitan,

    Nice to hear from you and this thread will definitely help others with this specific issue.

    Thanks,

    Raziq

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: get Parameter from Contract class to DP class

    I did several changes, that may help (some of them or one of them are the key to the solution - too late to check them all, but for farther process, I can deal with that issue).

    1. I don't know what I did to do refresh - just coincidence, but the value of param setting to 123 is getting in the processreport, and every change.

    2. I think not just CIL compilation, but adding a line (such as remark), do the different.

    3. Also, the sysEntryPointAttribute may helped.

    4. I shall not use common - I think this may lead to some data miss. So I add a buffer (the table data field).

    5. About debug - I can do debug only within AX, but not from SSRS. The declaration are fine, but I cannot reach the breakpoint in processreport. Nevertheless, I add a log table - That is fine with me.

    Thanks, anyway :)

  • Mohammad Raziq Ali Profile Picture
    Mohammad Raziq Ali 2,432 on at
    RE: get Parameter from Contract class to DP class

    Hi Eitan,

    That's not good, you try to  run report from Visual Studio by putting a static debugger in processReport() method and go with this link below that would help you to debug report data provider class.

    technet.microsoft.com/.../gg724081.aspx

    & go through with this below doc as well

    axugsummit.com/.../A1218.pdf

    Thanks,

    Raziq

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans