Best Practice ‘Best Practices’ in MorphX Coding

By Bill Thompson | September 8, 2014

I ran into this a while back while working in Dynamics AX 2012, and it just reinforces that you really need to think through your design when coding methods in MorphX.
First, a description of the scenario. A table has been created that will be used as a temporary (InMemory) table. There will be conditions where we want to do a find on that table to see if a record already exists, and if so, update a value based on some calculations performed.
The issue. By default, a "Best Practice" is to create a static method on the table called find that returns the record that you desire. The problem is, this is a static method that will look at the table in the database. Since this is a memory based table, we have nothing in the database to examine.
The resolution. An instance method on the table is needed. That way, the search will be done on the table buffer that is defined in your code (the instance), and not the database defined object.
I just wanted to bring this up as something to keep in the back of your mind as you develop. Scope and instance can really play a part in how you retrieve data, and this is something that a less experienced developer may run into on occasion.

Related Posts


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!