web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to retrieve the SalesLine ItemID in SSRS Report parameter based on selected Line - x++

(4) ShareShare
ReportReport
Posted on by 275
Hello,
 
im developing a custom ssrs report, i need it to print data based on selected sales line itemid. so lets say i have a sales order with 3 sales lines, and i select the 1st row, it should get me the data based on the first row's itemid ,knowing that each row has a different itemID. i developed the Contract, controller and DP classes. after debugging the code, i found that in the  processReportParameters() method in the controller class, the buffer "contract" is always null, which is related to the contract class. when i try to print the report, its giving always error that "Something went wrong while generating the report. Please try again."
 
i would appreciate your help in my issue.
Thanks
[DataContractAttribute]
class ContractClasz
{
    private ItemId itemId;


    [DataMemberAttribute('ItemId')]
    public ItemId parmItemId(ItemId _itemId = itemId)
    {
        itemId = _itemId;
        return itemId;
    }

}
public class SalesControllerClasz extends SrsReportRunController
{
    protected void PrePromptModifyContract()
    {
        ContractClasz contract = this.parmReportContract().parmRdpContract();
        this.processReportParameters(contract);

    }
    void processReportParameters(ContractClasz _contract)
    {
        ContractClasz contract;
        SalesTable SalesTable;
        SalesLine SalesLine;

        if(this.parmArgs().record().TableId == tableNum(SalesLine))
        {
            if(this.parmArgs() && this.parmArgs().record())
            {
                contract = this.parmReportContract().parmRdpContract() as ContractClasz ;
                SalesLine = this.parmArgs().record();
            }
            _contract.parmItemId(SalesLine.ItemId);
          
        }
    }
    public static void main(Args _args)
    {
        SalesControllerClasz controller = new SalesControllerClasz();
        controller.parmArgs(_args);
        controller.parmReportName(ssrsReportStr(ReportTTT, Design));
        controller.startOperation();
    }

}
 
Categories:
I have the same question (0)
  • Suggested answer
    Vishal Tiwari Profile Picture
    393 on at
    Hi,
     
     
    Contract Class Issue: Ensure your contract class has the correct DataMember attribute and is correctly initialized in the controller.
    Passing Parameters: The controller should correctly pass the selected SalesLine’s ItemId to the contract.
    processReportParameters() Issue: If the contract is null, check if it's properly assigned using parmRdpContract().
    DP Class Filtering: Ensure your DP class retrieves the contract and filters data based on ItemId.
    Menu Item Data Source: If your report is tied to a specific table, the menu item in the data source should point to the correct table.(check the form etc)
    Debugging: Add breakpoints in processReportParameters() and verify args.record() to confirm you're getting the selected SalesLine.
     
    Thank you!
     

    *If this resolved your issue, please mark it as "Verified" to assist others facing the same problem*

  • Layan Jwei Profile Picture
    8,165 Super User 2026 Season 1 on at
    Hi,
     
    When you debug, does it reach this line?
    contract = this.parmReportContract().parmRdpContract() as ContractClasz;
  • Martin Dráb Profile Picture
    238,745 Most Valuable Professional on at
    You need to use the debugger to find the actual exception.
     
    Your code in processReportParameters() is weird:
    • Whether contract variable is null or not isn't important, because you never use it for anything.
    • You're using the value of salesLine.ItemId even if you didn't populate salesLine variable.
    • You're using the value of this.parmArgs().record() before checking whether you have any Args at all. You need to change the order of the conditions.
    • You've declared salesTable variable, but you never use it.
  • Verified answer
    Aymen CHELBI Profile Picture
    580 Super User 2026 Season 1 on at
    Hello, 
     

    Try modifying this part of the code as follows : 

     

    public class SalesControllerClasz extends SrsReportRunController
    {
        protected void PrePromptModifyContract()
        {
            ContractClasz contract = this.parmReportContract().parmRdpContract() as ContractClasz;

            if (!contract)
            {
                contract = new ContractClasz();
                this.parmReportContract().parmRdpContract(contract);
            }
            this.processReportParameters(contract);
        }
        void processReportParameters(ContractClasz _contract)
        {
            SalesLine salesLine;
            if (this.parmArgs() && this.parmArgs().record().TableId == tableNum(SalesLine))
            {
                salesLine = this.parmArgs().record() as SalesLine;
                if (salesLine)
                {
                    _contract.parmItemId(salesLine.ItemId);
                    // Ensure the contract is updated in the report contract
                    this.parmReportContract().parmRdpContract(_contract);
                }
            }
        }
        public static void main(Args _args)
        {
            SalesControllerClasz controller = new SalesControllerClasz();
            controller.parmArgs(_args);
            controller.parmReportName(ssrsReportStr(ReportTTT, Design));
            controller.startOperation();
        }
    }
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 558 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 402

#3
Diego Mancassola Profile Picture

Diego Mancassola 261

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans