AL icon indicating copy to clipboard operation
AL copied to clipboard

this keyword does not work properly extension objects, table-, report-, page-

Open navdotnetreqs opened this issue 9 months ago • 2 comments

this.Calcfields(New_Field) run in a table extension does not find New_Field if it is declared in a table extension.

It seems that the this-keyword on a table extension refers to the base table, and does not consider extension fields (at least not in the same object). Thus we get conflicting requirements from the analyzer, where on the one hand we must use this, but on the other hand the field is not found if we use this.

Image

AL[AA0248] tells me I must use the THIS keyword for the calcfields. However, if I add it:

Image

AL0847 won't event let me compile.

We can use "Rec." though, but that's not what AA0248 says we should do, so maybe it's an issue with the analyzer..?

navdotnetreqs avatar Feb 24 '25 08:02 navdotnetreqs

Same goes for page extensions. If we use a variable, we obviously cannot use Rec. "this" is recommended, but "this" fails:

Image

error AL0847: 'Page Microsoft.Purchases.Document."Purchase Order"' does not contain a definition for

navdotnetreqs avatar Feb 24 '25 09:02 navdotnetreqs

It does not work for report extensions either. We get a warning that we need to add this Add 'this' qualification.AL[AA0248](https://learn.microsoft.com/dynamics365/business-central/dev-itpro/developer/analyzers/codecop-aa0248?wt.mc_id=d365bc_inproduct_alextension)

But if I add this Report Microsoft.Sales.History."Standard Sales - Invoice"' does not contain a definition for 'FinanceChargeTerms_ASDF'

navdotnetreqs avatar Mar 25 '25 08:03 navdotnetreqs

Will it ever be fixed?

navdotnetreqs avatar Sep 01 '25 05:09 navdotnetreqs

Will it ever be fixed?

The "requires-triage" label tells you it was not even prioritized as one of the next fixes.

NKarolak avatar Sep 01 '25 06:09 NKarolak