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 :
Microsoft Dynamics AX (Archived)

How to initialize the contract class parameter

(0) ShareShare
ReportReport
Posted on by 2,055

I am using AX 2012 and have developed a report using the class and have use the contract class for customer parameter like 'From Date' and 'To Date'.

Now I want to initialize the 'From Date' with some date  like 01\07\2013 how I can do this. My class code is as follow.

//class declaration
[DataContractAttribute]
public class CustomerBalancesQryContract
{
    FromDate  StartDate;
    ToDate ToDate;
    boolean WithoutOpening ;

    //AccountName accountName;implements SysOperationValidatable
    //
    #define.parameterStartDate('StartDate')
    #define.parameterToDate('ToDate')
}

// function declaration

[DataMemberAttribute("ToDate"),
SysOperationLabelAttribute(literalStr("@SYS14656"))
]
public TransDate parmToDate(TransDate _ToDate = ToDate)
{
    ToDate = _ToDate;
    return ToDate;
}

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Dennis Huesmann Profile Picture
    on at

    Hello,

    you can change your contract's class declaration to implement the interface SysOperationInitializable.

    Then add your initialization logic to the initialize() method.

    The SSRS report framework in AX will then call this method after instanicating your contract class.

    Best Regards

    Dennis

    P.S.: The same logic works for the interface SysOperationValidatable and method validate().

  • Dick Wenning Profile Picture
    8,705 Moderator on at

    in case of using in combination with reports extend the

    SRSReportRunController

    example SalesQuotationConfirmationController

  • Nadeem Bhatti Profile Picture
    2,055 on at

    Thanks Dennis

    Can you please give me some example to assign value to parameter, I have use the following code after implementing the SysOperationInitializable but its not working

    public void initialize()

    {

       StartDate=01\07\2013;

       WithoutOpening=true ;

    }

    while class declaration is as under

    public class CustomerBalancesQryContract extends SrsReportRdlDataContract implements  SysOperationInitializable

  • Dennis Huesmann Profile Picture
    on at

    When using a contract that extends SrsReportRdlDataContract use the method setValue() of this super class.

    In your case it would look like this:

    this.setValue('StartDate', 01/07/2013);

    this.setValue('WithoutOpening', true);

    Note that the string you pass into the method is the parameter's name as specified in the report itself.

    By the way, you seem to use these parameters in your report data provider class. In this case you might not want to extend class SrsReportRdlDataContract, because you usually use this class for parameters that are only created in the report object itself.

    The class in your original post looks like an RDP contract class from which report parameters are created automatically when refreshing the report's datasets.

    Please refer to following TechNet article for further information on the difference between RDL and RDP contracts: technet.microsoft.com/.../dn249829.aspx

  • Nadeem Bhatti Profile Picture
    2,055 on at

    Thanks Dinnes

    For your help, yes I am using these parameter for RDP class and I have change the definition of class with the following

    public class CustomerBalancesQryContract implements  SysOperationInitializable

    The following code was not working for current scenario

    this.setValue('StartDate', 01/07/2013);

    So I have use following code in initialize method and it is working. As parmStartDate is the member of contract class.

       this.parmStartDate(01\07\2013);

  • Dennis Huesmann Profile Picture
    on at

    I'm glad this solution worked for you.

    Just to clarify: The setValue() method is a method of class SrsReportRdlDataContract and therefore can only be called if you extend that class.

    When using SrsReportRdlDataContract your parameters are not stored in global variables of your contract class but in objects of class SRSReportParameter, so you have to call setValue() in order to change those objects.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans