web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Access variables in ex...
Finance forum

Access variables in extension class using chain of command

(0) ShareShare
ReportReport
Posted on by 2,426

Good morning,

I have created one extension class for Class - SalesConfirmJournalCreate

there is a method called SalesConfirmJournalCreate.createJournalHeader()

i have created extension class for SalesConfirmJournalCreate

i have copied same method and after next statement i need to initialize some values for CustConfirmJour - Table

[ExtensionOf(classStr(SalesConfirmJournalCreate))]
Final class MSAXSalesConfirmJournalCreate_Extension
{
protected void createJournalHeader()
{
next createJournalHeader();
// How can i access custconfirmjour variable
}

}

 

How can i access members of SalesConfirmJournalCreate in extension class.

Please provide some help on this.

Regards.

Have a great day.

  • Suggested answer
    Shahil Profile Picture
    635 on at

    When you wrap a method, you can also access public and protected methods and variables of the base class.

    CustInvoiceJour is a base class variable hence you will be able to access it. Eg.

    [ExtensionOf(classStr(SalesConfirmJournalCreate))]
    Final class MSAXSalesConfirmJournalCreate_Extension
    {
       protected void createJournalHeader()
       {
         next createJournalHeader();
    
         //It's as simple as this:
         custConfirmJour.SalesBalance = 0;
    
       }
    
    }
  • AX 2012 r3 Profile Picture
    2,426 on at

    Heloo,

    Please check this.

    Errrrrrr.png

    My VM is the new version .

    and the error is 

    "The qualifier custconfirmjour is not valid in this context"

    Regards.

  • Verified answer
    Mea_ Profile Picture
    60,286 on at

    Hi AX 2012 r3,

    It's an old bug with variable names. Declare new one and use it:

    protected void createJournalHeader()
    {
        next createJournalHeader();
        CustConfirmJour    custConfirmJourLocal = custConfirmJour;
        custConfirmJourLocal.MyField = 'blah-blah';
    }


  • AX 2012 r3 Profile Picture
    2,426 on at

    Thanks Ievgen

  • ist Profile Picture
    805 on at

    Is that bug already fixed?

  • nmaenpaa Profile Picture
    101,174 Moderator on at

    You should be able to find out by installing latest version and trying yourself. Please share the result with us. Thanks!

  • Bill Pfingsten Profile Picture
    Microsoft Employee on at

    Apparently still not fixed, as I just ran into it today.  (D365 version 10.0.18 + PU42)

  • DerSascha Profile Picture
    77 on at

    This bug still exists. Seems to be a problem especially when the variable name used in the standard-code is the same as the AOT name  (SalesTable salesTable;)....

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans