AX 2012 Method -Accessor method

By Laura Lake | February 10, 2014

AX 2012 Method -Accessor method

For developers who are new to AX, and especially those coming from other products, the Accessor method, a type of AX 2012 Method,

may be a little confusing at first. You may be used to seeing the Get/Set keywords used like this…

{

    private string _mystring;

 

    public string mystring

    {

             get { return _mystring; }

             set {_mystring = somevalue;}

 

    }

}

AX 2012 Method 

In an AX 2012 Method, the same logic would be expressed in this way…

{

    str myString;

 

    publicstr myString(str _myString = myString)

    {

             myString = _myString;

             return myString;

    }

}

Get and Set happen here in the same method.

If the method is called with parameter_myString having a value, then the class variable (myString) is set to this value…

myString = _myString;

If the method is called without a parameter, the parameter defaults to the class variable…

(str _myString = myString)


Under the terms of this license, you are authorized to share and redistribute the content across various mediums, subject to adherence to the specified conditions: you must provide proper attribution to Stoneridge as the original creator in a manner that does not imply their endorsement of your use, the material is to be utilized solely for non-commercial purposes, and alterations, modifications, or derivative works based on the original material are strictly prohibited.

Responsibility rests with the licensee to ensure that their use of the material does not violate any other rights.

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!