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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Controller class -SSRS

(0) ShareShare
ReportReport
Posted on by 275

Hi ,

     This is my Controller class code with two Report Design .

public class GD_CustTransController extends SrsReportRunController
{
public static void main(Args _args)
{
GD_CustTransController controller = new GD_CustTransController();

controller.parmReportName(ssrsReportStr(GD_CustTrans,Report_Group));
controller.parmArgs(_args);
controller.startOperation();

}
protected void preRunModifyContract()
{
GD_CustTransContract contract = this.parmReportContract().parmRdpContract() as GD_CustTransContract;

if(contract.parmCustGroup() != '')
{
this.parmReportContract().parmReportName(ssrsReportStr(GD_CustTrans,Report_Group));
}
else
{
this.parmReportContract().parmReportName(ssrsReportStr(GD_CustTrans,Report_Account));
}
}
}

But I dont see my controller class is working properly with the respective Report as per the if condition.

It works only based on the default report which I have mentioned in output menu items property. Can someone Explain why it always selects the (Report_Account) Report design .

Do I need to make any changes in my controller class in order to call my Another report ?

pastedimage1652448071759v1.png

I have the same question (0)
  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    Your code is very difficult to read, because you added it in a wrong way and all line indentations got lost. Next time, use Insert > Code (in the rich formatting view). This is the result:

    public class GD_CustTransController extends SrsReportRunController
    {
    	public static void main(Args _args)
    	{
    		GD_CustTransController controller = new GD_CustTransController();
    
    		controller.parmReportName(ssrsReportStr(GD_CustTrans,Report_Group));
    		controller.parmArgs(_args);
    		controller.startOperation();
    	}
    		
    	protected void preRunModifyContract()
    	{
    		GD_CustTransContract contract = this.parmReportContract().parmRdpContract() as GD_CustTransContract;
    
    		if(contract.parmCustGroup() != '')
    		{
    			this.parmReportContract().parmReportName(ssrsReportStr(GD_CustTrans,Report_Group));
    		}
    		else
    		{
    			this.parmReportContract().parmReportName(ssrsReportStr(GD_CustTrans,Report_Account));
    		}
    	}
    }

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    What did you find when you debugged your code? Does the condition works as expected?

  • Noob Gamer Profile Picture
    275 on at

    Hi Martin,

           I am new to D365 , I have not tried debugging in f&o . How can I debug after Deploying Reports ?

    Or which class should I have to make as a startup object inorder to debug ?

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    There are other ways, but let's use the simplest one. Put a breakpoint to your class. Highlight the class in Solution Explorer, right-click and choose "Set as startup object". Then press F5 to run the project.

    There is a saying: “Writing code accounts for 90 percent of programming. Debugging code accounts for the other 90 percent!”. Knowing how to debug code is crucial; invest time into learning how to do it.

  • Noob Gamer Profile Picture
    275 on at

    Hi Martin,

           I am getting this Error when I try to Debug the Report . Should I have to enable something ? 

    pastedimage1652696821663v1.png

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    I see you're using Visual Studio and I don't think that it's correct. I don't think that you've calling your controller from an IL session. I assume you just open it by a menu item or run the class directly, therefore it runs as X++ and you should use the X++ debugger.

  • Suggested answer
    abdultp Profile Picture
    867 on at

    Hi,

    As you're calling the report through controller class, in the output menu item change the object type to 'class', object to 'GD_CustTransController' & leave the report design as blank.

  • NoobGamer Profile Picture
    2 on at

    Hi, 

        I can able to call my controller class and It works , But I need to Debug the SSRS in Visual Studio , How can I do That , Can you please share me any link regarding debugging 

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    It's great that your precious problem gets resolved and now you understand how to debug your class.

    What exactly do you want to debug in SSRS?

    Regarding links, the first place to look at is the official AX 2012 documentation. Make you get used to consulting it. For example, look at these pages:

  • NoobGamer Profile Picture
    2 on at

    I want to Debug since I need to understand the basic flow of contract,controller,DP and UIDesigner Classes. I mean from the scratch .

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans