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, ...
Answered

How to make my controller class read contract class ?

(1) ShareShare
ReportReport
Posted on by 552
Hi, 
 
When creating SSRS report, I'm adding a selection in my Data Contract Class, which the plan is to determine it will process a detail or a summary report. In the SSRS report it self, it will have 2 design, for detail and summary.
Question is, in my controller class, what should I write to read that result selection from contract class ?
 
In some blog or thread, I found some example of needed to method  preRunModifyContract(). May I know  it looks ? and how about the method main().
I used to put the report name and design in this main() method. Something like this:
 
        controller.parmReportName(ssrsReportStr(ItemSummaryReport,Empty));        controller.parmArgs(_args);        controller.startOperation();
 
But now what should the main method() need to be written, while we have preRunModifyContract(). 
 
Thanks.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
I have the same question (0)
  • Suggested answer
    Layan Jwei Profile Picture
    8,112 Super User 2025 Season 2 on at
    Hi Ken,
     
    I didn't quite understand the requirement. So are you selecting records from grid and want to pass them to the report? Can you please elaborate more what are you trying to do?
     
    In general to get the contract in the controller class, you need to do this line of code
    ContractClass contract = this.parmReportContract().parmRdpContract() as ContractClass;
     
    Also don't forget to define the contract attribute in the RDP class
    [SRSReportParameterAttribute(classStr(ContractClass))]
     
    And here's an example on how you can use preRunModifyContract:
     
    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
     
  • Ken Manhattan Profile Picture
    552 on at
    Hi Layan,
     
    No, the report will run without looking at some record in grid.
    In RDP class, I already catch this selection from contract class, so when user select summary, it will run different method, also I created 2 different TempTable. It is something like this:
    class SummaryDetailRptRDP extends SrsReportDataProviderPreProcessTempDB
    {
        DetailRptTmp  detailRptTmp;
        SummaryRptTmp   summaryRptTmp;
    
        [SrsReportDataSet(tableStr(MYReportRptTmp))]
        public DetailRptTmp  getDetailRptTmp()
        {
            select detailRptTmp;
            return detailRptTmp;
        }
    
        [SrsReportDataSet(tableStr(MYReportRptTmp))]
        public SummaryRptTmp getSummaryRptTmp()
        {
            select summaryRptTmp;
            return summaryRptTmp;
        }
    
        public void processReport()
        {
            MYRptContract   contract = this.parmDataContract() as MYRptContract;
            fromDate = contract.parmFromDate();
            toDate = contract.parmToDate();
            isSummary =  contract.Summary();
    
            if (!isSummary)
            {
                //processing detail
                this.insertDetailTmp();            
            }
            else
            {
                //processing summary
                this.insertSummaryTmp();
    
            }
    
        }
    
    
        public void insertDetailTmp()
        {
    
            delete_from detailRptTmp;
            this.takeOwnershipOfTempTable(detailRptTmp);
            detailRptTmp.setConnection(this.parmUserConnection());
    
    	<logic to insert detail tmp>
        }
    
        public void insertSummaryTmp()
        {
    
            delete_from summaryRptTmp;
            this.takeOwnershipOfTempTable(summaryRptTmp);
            summaryRptTmp.setConnection(this.parmUserConnection());
    
    	<logic to insert summary tmp>
        }
    
    
    }
     
    Hope it is correct though. Haven't test because of the controller.
     
    It is just, now I have doubts what would be the controller like. For start, should I create 2 output menu item ? with specifying "parm" ? but I feel odd why I need that, since my mind tell it should be only 1 output menu item and specify only to this controller class, and let controller class read my contract class selection, "similar" to the RDP. But then again, I'm pretty confuse what to do and what method needed and how the code looks like ?
     
    Thanks.
     
     
  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at
    When do you decide which report should be used? Your description ("which the plan is to determine it will process a detail or a summary report" and "let controller class read my contract class selection") is completely unclear to me.
     
    Do you want a user to select it in the dialog? To have code in the controller making the decision somehow? Will is it decided by code calling the controller? Or somehow else?
  • Ken Manhattan Profile Picture
    552 on at
    The selection is in Dialog, hence I put in contract class.
     
    And it will not read any record from any grid. It will just run by call from navigation pane, shows the dialog, there is selection which is just a check box to stated that the user wants Summary. If not check means user wants Detail report.
     
    Hope it is clear.
     
    Thanks.
  • Suggested answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at
    Then using preRunModifyContract() makes sense to me. There you can do something like this:
    MyContract contract = this.parmReportContract().parmRdpContract();
    str reportName = {condition} ? ssrsReportStr(MyReport, Summary) : ssrsReportStr(MyReport, Detail);
    
    this.getReportContract().parmReportName(reportName);
     

     
  • Ken Manhattan Profile Picture
    552 on at
    Hi Martin,
     
    Thanks, I will try. But what should I do inside the main() method ?
    Because if I take a look at few samples or blogs, in the main() method also have logic to specified the report and which design ?
    If looking at your example for preRunModifyContract() ? it is also have logic to determine report and which design.
     
    Thanks again.
     
  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at
    main() method is related to your requirement. There you'll just call startOperation() and all the important logic is inside. It's too early to do anything before startOperation() (because user couldn't make a selection yet) and too late after startOperation() (because the report already ran), therefore main() is a wrong place.
     
    The blogs you looked at must have been about different requirements than yours.
  • Suggested answer
    Layan Jwei Profile Picture
    8,112 Super User 2025 Season 2 on at
    Hi Ken,
     
    The requirement wasn't very clear.
    So based on the contract parameter selection, you need to call a different report design right?
     
    My first reply is still valid.
    You still need this line of code to get the contract
    ContractClass contract = this.parmReportContract().parmRdpContract() as ContractClass
     
    And the link I showed you on how to use the preRunModifyContract is also valid
    Now what you need to do in it is like Martin said.
    If(contract.parmDesign()==summary)
    {
    this.parmReportContract().parmReportName(ssrsReportStr(YourReport, Summary));
    }
     
    Else
    {
      this.parmReportContract().parmReportName(ssrsReportStr(yourReport, Detail));
    }
     
    Thanks,
    Layan Jweihan 
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
  • Ken Manhattan Profile Picture
    552 on at
    Hi both,
     
    Sorry, I seems a bit confuse now. After Martin's reply, I tried this, as I kinda get what his mean, about just call start operation in main() method :
    class MYRptController extends SrsReportRunController
    {
    
        public static void main(Args _args)
        {
            MYRptController controller = new MYRptController();
                    
            controller.parmShowDialog(true);
            controller.startOperation();
        }
    
    
        public void preRunModifyContract()
        {
            MYRptContract   contract = this.parmReportContract().parmRdpContract();
            
            str reportName = contract.Summary() ? ssrsReportStr(MYReport, Summary) : ssrsReportStr(MYReport, Details);
    
            this.getReportContract().parmReportName(reportName);
        }
        
    }
     
    It feels right, however got error :  "A local variable named 'reportName' cannot be declared in this scope because it would give a different meaning to 'reportName', which is already used in a parent or current scope to denote something else."
     
    Thanks
  • Suggested answer
    Layan Jwei Profile Picture
    8,112 Super User 2025 Season 2 on at
    Hi Ken,
     
    Just rename the variable to sth else. Or say reportName=... Without declaring it as it's already defined. Or do like i showed you
     
    contract.Summary()?this.parmReportContract().parmReportName(ssrsReportStr(YourReport, Summary)) : this.parmReportContract().parmReportName(ssrsReportStr(yourReport, Detail));
     
    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future

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