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)

Dynamics object not initialized

(0) ShareShare
ReportReport
Posted on by 4,624

Hi All,

I am following below blog  for learning new things in AX: https://community.dynamics.com/ax/b/daxmusings

Today ,I was reading below post on this blog : http://daxmusings.codecrib.com/2014/11/ax2012-extension-framework.html

and tried to do same in my test environment and i am successful in first step (using Sub class and constructors  ) but when i tried to do with extension (with attribute class) and run main method it gives me error

Dynamics object not initialized "  even i read Joris told "our static main was already using construct, you can just re-run the main "  so i haven't changed main mathod . my main method & construct is looks like :

7115.main.PNG    construt.PNG

your suggestion on this would be appreciated. 

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    If you use the debugger (which you should do every time when trying to debug your code), you'll likely find that getClassFromSysAttribute() returns null and you obviously can't call methods on null references. Therefore the problem is in the part that you didn't show us - review again that your class inheritance and attributes are set properly, and consider if you can't have wrong values in the cache.

  • Rohin Profile Picture
    4,624 on at

    I used debugger on construct method and i found (_products gets the value "AX" but dynamics object is set to null) . I am getting not any help from this . Note i have reviewed again all and its exactly same as in blog . can you suggest on this ?

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    As I said, the problem is a different part of code than what you showed us. You expect people to find bugs in your code if you don't show or at least describe what you've done. If you think that your code is correct, maybe it's the cache, as I suggested at the end of my reply.

    If you want to know exactly what happens and where, use the debugger to walk through code inside getClassFromSysAttribute().

  • Mea_ Profile Picture
    60,284 on at

    Hey Visvash Walia,

    Did you try to follow instructions in the end of the blog post regarding the cache ?

    "...it may not pick up new classes or changed attributes. From the Tools menu, you can run Tools / Caches / Refresh Elements to flush the cache so it will pick up your changes."

  • Rohin Profile Picture
    4,624 on at

    Okay , I''ll show you other part of code:-

    Dynamics Class code :

    0523.4.PNG     4743.2.PNG

    Other Main() and construct() method of this class already shared above.

    DynamicsProductsAttribute Class  code :

    7457.3.PNG  0523.4.PNG

     

    3247.5.PNG

     

    DynamicsAX class Code:

    1680.6.PNG  5314.7.PNG

     


    Would be great if you find any wrong in above code ? 

    And, I already refresh Elements (Tools >cache >RefreshElement) mentioned in blog. but not helps.

     

     

  • Rohin Profile Picture
    4,624 on at

    Hello Ievgen ,

    I already did . but not helps

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    I think the bug is in the fact that the constructor of DynamicsProductsAttribute class requires a parameter. Remove it and try it again.

    By the way, I think that putting code here would be easier for you (you don't have to make and upload images), it would show more information (you could easily include all methods) and it would allow people to copy your code and run it, which would increase chances to get an answer.

  • Rohin Profile Picture
    4,624 on at

    If i am understanding you correctly, I need to remove parameter of New constructor of DynamicsProductAttribute Class ??

    If so, then how can i decorate my subClass(DynamicsAX) ??

    And i'll keep in mind next time to post directly code not images.

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Ah, sorry, that's the attribute. I got confused by all those images and I thought I was looking at the sub-class.

  • Rohin Profile Picture
    4,624 on at

    hi Martin ,

    I found the error but i really don't understand this .

    Error is in parameter of New () of DynamicsProductAttribute Class , and I changed the code to :

    public void new(DynamicsProducts _dynamicsproducts)
    {
    super();
    this.parmDynamicsProducts(_dynamicsproducts);
    }

    Notice : before It was (DynamicsProducts _products ) and now it changed to (DynamicsProducts _dynamicsProducts).


    And now it works correctly and give result .

    But i want you to give suggestion on this please why it behaves so ?

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
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans