Skip to main content

Notifications

Announcements

No record found.

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

  • RE: How to initialize the contract class parameter

    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.

  • Nadeem Bhatti Profile Picture
    Nadeem Bhatti 2,055 on at
    RE: How to initialize the contract class parameter

    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);

  • RE: How to initialize the contract class parameter

    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
    Nadeem Bhatti 2,055 on at
    RE: How to initialize the contract class parameter

    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

  • Dick Wenning Profile Picture
    Dick Wenning 8,705 on at
    RE: How to initialize the contract class parameter

    in case of using in combination with reports extend the

    SRSReportRunController

    example SalesQuotationConfirmationController

  • Verified answer
    RE: How to initialize the contract class parameter

    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().

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans