microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
744 stars 245 forks source link

Definition for field does not exist for field of type enum (AL0132) in dependent app #6275

Closed jimmymcp closed 2 years ago

jimmymcp commented 3 years ago

I have an app (call it PROD) with a table of type enum which uses a the Sales Line Type enum from the base app. I also have a test app (call it TEST) which is dependent upon the first.

I can see my enum field in intellisense when working in TEST but the compiler throws an error saying that the definition of the field cannot be found. For now I have had to workaround using SetFieldValue from the Data Type Management codeunit.

I have the same behaviour with a table extension in PROD adding a field to a standard table of type enum with an enum that is defined in PROD. Again, when developing in TEST I can write the code to assign the field value but the compiler throws an error. Again, using SetFieldValue is a workaround for now.

AL Language v6.1.359074

atoader commented 3 years ago

Can you provide a set of sample projects that reproduce the issue and a video of the unexpected behavior?

jimmymcp commented 3 years ago

I've just tried a simple repro and it works as expected. I will harder to break it later, for now this is a snip of my code and the compiler output.

image

The Type field is a "Sales Line Type" field and the table belongs to the PROD app. The compiler error is in the TEST app.

jimmymcp commented 3 years ago

Actually, looks like there is something more fundamental here. Hopefully you can see in this gif that my field shows in intellisense but fails to build. Not sure how to get more info about what is going on here? This field is supplied by a table extension in the PROD app. I'm attempting to reference in and build the dependent TEST app.

Compilation Error

jimmymcp commented 3 years ago

Update: I had been disabling code analysis in the TEST app. Enabling that (CodeCop, UICop) solves the problem 🤔

NKarolak commented 3 years ago

I saw something far related when my project references were not correctly defined, or when they weren't loaded yet.

Could you try the following?

  1. Enable the code analysis again
  2. In TEST, check that dependency to PROD contains the exact, current PROD version number. // project reference
  3. Publish PROD, publish TEST
  4. Reload Window (not sure it's actually needed).
  5. Open any PROD object, then any TEST object. // reference load
  6. Try to reproduce
thloke commented 2 years ago

Hi! In the last months, we've been working hard on adding new features that increase your productivity and on improving the quality of the tools. Unfortunately, this meant that we were not able to follow up on as many GitHub issues as we would have liked.

If this is still a problem in the latest insiders build, feel free to raise this issue again.