Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

SSRS report error - Parameter doesn't get passed

Posted on by 524

Hi Experts,

I have created a custom SSRS report which needs to be printed from a form i.e.. the argument should pass to the report from the form. The report does not work and gives me the error while trying to generate, A value must be provided for the parameter Load Id. I will provide my code here, can anyone help me to find out if i missed something or what is the issue with the code please. Load id is my parameter for the report. 

Contract class:- 

[DataContractAttribute]

public class SalesLoadPackingSlipContract

{

    WHSLoadId   LoadId;

    

    [

        DataMemberAttribute('Load Id'),

        SysOperationLabelAttribute(literalStr(/Load Id/)),

        SysOperationControlVisibilityAttribute(true)

    ]

    

    public WHSLoadId parmLoadId(WHSLoadId _LoadId = LoadId)

    {

        LoadId = _LoadId;

        return  LoadId;

    }

}

 

Controller class:- 

class SalesLoadPackingSlipController extends SrsReportRunController
{       
    public static void main(Args _args)
    {
        SalesLoadPackingSlipController    controller = new SalesLoadPackingSlipController();
        WHSLoadTable wHSLoadTable;
        wHSLoadTable = _args.record() as wHSLoadTable;
        controller.parmArgs(_args);
        controller.parmReportName(ssrsReportStr(SLoadPackingSlip, Common));
        controller.parmShowDialog(false);
        controller.startOperation();
    }
}
 
DP Class:-
 
[SRSReportParameterAttribute(classStr(SalesLoadPackingSlipContract))]
class SalesLoadPackingSlipDP extends SRSReportDataProviderBase  //SrsReportDataProviderPreProcess //
{
    //contract Class
    SalesLoadPackingSlipContract  salesLoadPackingSlipContract;
    //Temporary Tables to get report Data
    LoadPackingSlipHeaderTmp   loadPackingSlipHeaderTmp;
    LoadPackingSlipLineTmp     loadPackingSlipLineTmp;
 
    //Data Tables
    CompanyInfo            companyInfo;
    CustPackingSlipJour    custPackingSlipJour;
    CustPackingSlipTrans   custPackingSlipTrans;
    WHSLoadTableCustPackingSlipJour wHSLoadTableCustPackingSlipJour;
    
    //Report Parameter value
    WHSLoadId       LoadId;
    [SRSReportDataSetAttribute(tablestr(LoadPackingSlipHeaderTmp))]
    public LoadPackingSlipHeaderTmp getLoadPackingSlipHeaderTmp()
    {
        select loadPackingSlipHeaderTmp;
        return loadPackingSlipHeaderTmp;
    }
    [SRSReportDataSetAttribute(tablestr(LoadPackingSlipLineTmp))]
    public LoadPackingSlipLineTmp getLoadPackingSlipLineTmp()
    {
        select loadPackingSlipLineTmp;
        return loadPackingSlipLineTmp;
    }
    private void getReportParameters()
    {
        salesLoadPackingSlipContract contract = this.parmDataContract();
        if (contract)
        {
            LoadId   = contract.parmLoadId();
        }
    }
    [SysEntryPointAttribute(false)]
    public void processReport()
    {
        //to fetch report parameters
        this.getReportParameters();
        companyInfo = CompanyInfo::find();
        CustTable       CustTable;
        WHSLoadLine     whsLoadLine;
        salesLoadPackingSlipContract = this.parmDataContract() as salesLoadPackingSlipContract;
        if(LoadId)
        {
            loadPackingSlipHeaderTmp.LoadId = LoadId;  // Added just one line for testing purpose
            loadPackingSlipHeaderTmp.insert();
        }
    }
}
  • Martin Dráb Profile Picture
    Martin Dráb 225,490 Super User on at
    SSRS report error - Parameter doesn't get passed
    I see you set wHSLoadTable in main(), but you never pass it to the contract class. You'd need to do something like this:
    SalesLoadPackingSlipContract contract = this.parmReportContract().parmRdpContract() as SalesLoadPackingSlipContract;
    contract.parmLoadId(wHSLoadTable.LoadId);
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    Mohamed Amine Mahmoudi 7,209 User Group Leader on at
    SSRS report error - Parameter doesn't get passed
    Hi @Alex,
     
    this problem has occurred when the parameter in report does not accept nullable or empty value.
    so you must go to the report and select the parameter and set :
    Allow blank true and nullable true.
     
    Best regards,
    Mohamed Amine MAHMOUDI

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