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)

Referencing object created in lower stack

(0) ShareShare
ReportReport
Posted on by

I apologize I am new too programming in general let alone x++. I want to modify the way the InventMovement\checkDImPhysical method handles some productions when I am posting reported as finished productions in the production module. When I am debugging I see that when I validate the RAF journal it originally calls the ProdJournalCheckPostProd class. Eventually in the call stack it uses the checkDimPhysical method from the InventMovement class and "this" contains the prodJournalProd table with a single production journal selected. When I try to edit the checkDimPhysical method by adding this.prodJournalProd I get a syntax error. If I print "this" I get no error.

The table isn't mentioned anywhere in this method or class I don't know how but is it possible that the object is from another class in the call stack. How can I use this information in this method or do I have to declare the table as variable and run a query to find it? 

I'm sorry if I am not clear if I need to reword this or provide more information please me know. 

if (this.dimSearch().dimPrimaryStocking())
                    {
                        okTmp = checkFailed(strfmt("@SYS54776",fieldid2pname(_inventDim.TableId, x)));


This is the line in the InventMovement\checkDimPhysical method that I want to add on to. The IDE isn't providing me the option for prodjournaltable when I type "this" as well, but it providing me other methods and properties instead.

Thank you.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mea_ Profile Picture
    60,284 on at

    Hi Jonx1000,

    InventMovement is a base class, for each table type it has a derived class that handles it. For prodJournalProd there are 3: InventMov_Prod_JournalProd, InventMov_Prod_JournalProd_CoBy, InventMov_Prod_JournalProd_Process. To find out which one you can put a breakpoint into InventMovement::constructNoThrow() method and see with one is created. Then you can override checkDImPhysical  method in one of those classes and do your check, don;t forget to call super() otherwise you would skip validation that is done in base method. Since prodJournalProd  is a variable you dont need to write "this.prodJournalProd" just "prodJournalProd" is enough.

  • Community Member Profile Picture
    on at

    Thank you it was InventMov_Prod_JournalProd.

    I overrided the method but theres no way I can use the okfailed variabke information from the base class right? I wanted to update the record based on that expression I quoted in my post.

  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    Why not ? You can do something like:

    public boolean checkDimPhysical(

       InventQty   _qty,

       InventDim   _inventDim,

       boolean     _finalCheck,

       boolean     _showError = true,

       boolean     _checkPalletLocation = true,

       Set         _specificDimensionsToCheck = null

       )

    {

       boolean ok = super();

       ok = ok && //you code here;

       return ok;

    }

    So boolean ok = super(); will execute base(standard) code and return result of execution.

  • Community Member Profile Picture
    on at
    When I tried to set super without any parameters its throwing an error. "ok" seems to be just returning a boolean, but not the
    checkFailed(strfmt("@SYS54776",fieldid2pname(_inventDim.TableId, x))); warning I was looking for. I've seen methods overried in the AOT with the same pattern you described not sure why its not working.
  • Mea_ Profile Picture
    60,284 on at

    It was not the exact code you should use, just an example. You have to pass all the parameters to the super, like 

    boolean ok = super(_qty, _inventDim, _finalCheck, _showError, _checkPalletLocation, _specificDimensionsToCheck ); 

    unless you want to change them before passing to the base method.

    checkFailed returns a boolean and adds message to the infolog, so if in the super you will hit next line

    checkFailed(strfmt("@SYS54776",fieldid2pname(_inventDim.TableId, x)));

    then ok would be false, because it's a boolean and message would be added to the infolog. 

  • Community Member Profile Picture
    on at

    Okay sorry I took it literally, I filled the parameters in for super and it worked. Thank you so now the overriden method works and I am able to access the prodJournalProd records thank you, but my last question is how can I access only those that are being triggered by that particular error. If ok returns false I'm assuming it can trigger false cause of another error it may not always be @SYS54776. Should I parse the infobox if possible or is there a better way I should perform this?

  • Mea_ Profile Picture
    60,284 on at

    Why do you need to know what the error was ?

  • Community Member Profile Picture
    on at

    I want to either delete the journal or subtract quantity from it based on the amount that has not actually been registered.

  • Verified answer
    Mea_ Profile Picture
    60,284 on at

    Then the easiest way for you (easiest not best) is to copy paste method from InventMovement to InventMov_Prod_JournalProd (forget about super()) and put your code wherever you need.

  • Community Member Profile Picture
    on at

    Okay i was able to modify those records on our development server. Just curious what would be a better method?

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