Al: CaptionClass is unnecessarily triggered

Created on 2 Oct 2020  Â·  7Comments  Â·  Source: microsoft/AL

Describe the bug

The CaptionClass property of a Field is triggered unnecessarily when opening a random Page (even with a different Source Record). The issue only occurs if there's a Query object referring to the Table for which the Field exists.

_P.S I hope this Bug can be handled here instead of re-submitting it via Collaborate since this clearly concerns an AL Developer Experience Bug. It's not clear anymore where to report what..._

To Reproduce

  • Create a Table Object with a Field which has a CaptionClass property assigned. The CaptionClass property refers to a function which throws an Error.
  • Create a Query Object for the Table and include all the Fields
  • Publish the Extension
  • Go to the Chart of Accounts page ==> The Error should be thrown.

NOTE: The issue also occurs when using the OnResolveCaptionClass event. (Also included in the sample)/

(See also Test Project in the attachments)

TestCaptionClass.zip

Expected behavior
The CaptionClass property should not be evaluated in this case.

Screenshots
Simulation CaptionClass

5. Versions:

image

  • Business Central:
    image
external

All 7 comments

Unfortunately you will have to submit it through collaborate unless you can repro it with the latest vsix and latest BC server.
Looks like a bug though.

This is our official answer:
This GitHub repository is dedicated to handling issues and feedback for the latest Developer Preview releases of the AL development tools for Dynamics 365 Business Central.

If you can reproduce the problem on the latest Business Central Developer preview version we will be happy to look further into it. Otherwise please contact the regular support channel.

You can open Support Request to CSS through PartnerSource portal or contact your Service Account Manager (SAM) in the local subsidiary to understand what is included in your contract as of support incident and PAH (Partner Advisory Hours). Your SAM might also step by step direct you how to open a support request or how to get credentials if this is the first time for you / your company.

For more details please read:
https://blogs.msdn.microsoft.com/nav/2018/05/03/al-developer-previews-multiple-releases-and-github/
https://github.com/Microsoft/AL/wiki/Frequently-Asked-Questions#i-found-an-issue-on-nav-2018-what-do-i-do

~I tested the attached project but could not replicate the error message, on GB Business Central 16.5 (Platform 16.0.15884.17299 + Application 16.5.15897.16082)~

edit: looks like I did it wrong, as per @fvet's comment below

@dtkb I've tested the attached project (had to remove the 'Navitrans Core' from the dependend apps). Publishing on a BC 17.0.16974.0 shows NO errors. Fine, since the query 50100 "Parcel Query" object in the attached project is commented by default.

If you uncomment query 50100 "Parcel Query", and publish again, I get the unexpected 'This code should not be triggered' error on a BC 17.0.16974.0

Some background why this should be fixed:

  • We've a large solution (one extension) with various modules making use of CaptionClasses. However, not all features are installed by default, or have been hidden using the ApplicationArea. The same is valid for the CaptionClasses. BC should not trigger / fail on a CaptionClass used somewhere in a module, even the module is not used, while accessing a random object outside of the module (strange thing is the problem only occurs in combination with the query object)

@fvet D'oh, I don't think I had uncommented the Query. Silly me to assume a repro would be ready to reproduce ;-)

Agreed, this seems like a clear-cut bug; if captions are not to be shown on the current object being viewed/rendered, then caption classes should not be evaluated or called.

We're the one to blame. We should have prepared our repro project better the first time :)

We're the one to blame. We should have prepared our repro project better the first time :)

@dtkb, @fvet

My apologies for the wasted time, I've overlooked this.

Was this page helpful?
0 / 5 - 0 ratings