Showing posts with label Declaration. Show all posts
Showing posts with label Declaration. Show all posts

Sunday, April 11, 2021

Access public variables in extension class using chain of command

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 SalesConfirmJournalCreate_Extension
{
protected void createJournalHeader()
{
next createJournalHeader();
//It's as simple as this:
custConfirmJour.SalesBalance = 0;
}
if gets an error, 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';
}
}

Table browser URL in D365FO

Critical Thinking icon icon by Icons8