AL icon indicating copy to clipboard operation
AL copied to clipboard

BC20.2 ControlAddIn Variable - error AL0157: 'VariableName' is not a valid variable type

Open catadumitru opened this issue 4 years ago • 15 comments

1. Describe the bug Compilation error when declaring a variable of type ControlAddIn Same as issue - https://github.com/microsoft/AL/issues/7055 but on the current released version - 20.2.41144.41423 2. To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
codeunit 50100 "PTE ControlAddIn Mgt"
{
    var
        t: ControlAddIn OAuthControlAddIn; // this errors out
    trigger OnRun()
    begin
    end;
}

3. Expected behavior This was not an issue in previous versions

4. Actual behavior Compile error

5. Versions:

  • AL Language:
  • Visual Studio Code:
  • Business Central: 20.2.41144.41423
  • List of Visual Studio Code extensions that you have installed:

catadumitru avatar Jun 10 '22 07:06 catadumitru

Hi @catadumitru, what version of the AL extension you are using, the one from marketplace or the one coming from docker container? If it is the one from marketplace, we haven't yet released the updated version, this will happen next week.

nndobrev avatar Jun 10 '22 08:06 nndobrev

This is the AL extension from the container as I first noticed this from a build pipeline.

Builds on 20.2 with the above code fail.

catadumitru avatar Jun 10 '22 09:06 catadumitru

Thank you, we will verify.

nndobrev avatar Jun 10 '22 09:06 nndobrev

Also, our appsource app cannot be installed on the new cloud version because of this issue.

catadumitru avatar Jun 10 '22 09:06 catadumitru

We also have this issue with our current Extensions. All of them use Control addin as a variable to encapsulate the handling of it to a codeunit and now they cannot be installed from AppSource witht he error message from the title in the current 20.2 version.

KoFrank avatar Jun 10 '22 13:06 KoFrank

We will check exactly what is happening because I remember we revert the change as it is mentioned here https://github.com/microsoft/AL/issues/7055#issuecomment-1137216978.

nndobrev avatar Jun 10 '22 13:06 nndobrev

We have Codeunits that

  • have global variables of ControlAddIn type,
  • copy them from Pages' ControlAddIns passed to an initialisation function in the Codeunit, and
  • do stuff with them afterwards in that Codeunit.

Thus I guess that

  • ControlAddIn is a reference type
  • whatever we were doing with it is OK, maybe because we reassign the global reference to point at a valid ControlAddIn instantiated by the Page, rather than the one instantiated (or not?) by the Codeunit

So I would think then that

  • our existing code will work again in the next version?
  • to avoid doing this, in case it again becomes an error later, we will have to pass the ControlAddIns to all functions in such Codeunits that need them, instead of 'storing' them as a global in the Codeunit... which seems a best practice anyway.

Do I understand correctly? Thanks!

dzzzb avatar Jun 14 '22 16:06 dzzzb

We are experiencing the same problem in an SaaS enviroment (version 20.2.41144.41547) when we try to install our extensions, this is pretty critical as we´re blocked with that customer.

oscarfernandezkurago avatar Jun 15 '22 05:06 oscarfernandezkurago

Hi @nndobrev Can you please let us know in which version this is/was expected to be fixed? I just tested it with the current SaaS version and still get the error.

Version in which we had the initial problem on friday: Version: GB Business Central 20.2 (Platform 20.0.41086.41862 Application 20.2.41144.41547

Version I tested with just now: Version: GB Business Central 20.2 (Platform 20.0.41086.42065 + Application 20.2.41144.41547)

In both cases the installation from AppSource fails with the following error:

Deployment failed. Errors: App ID : 5716c909-a743-461e-ac12-d99759152986 Message : { Extension compilation failed
src_Base_Module/NETVPSControlAddInShell.Codeunit.al(46,15): error AL0157: 'NetronicVSControlAddIn' is not a valid variable type } - Job Id : 5d74f919-06cf-4d05-bc42-53eb830ab9b6

The same applies to all our other extensions in appsource. This currently renders our complete product line (3 extensions) uninstallable/unusable in version BCv20.2

Looking forward to your feedback. I left the same comment in #7055 to follow up on both threads. Thank you very much.

SHermann73 avatar Jun 15 '22 12:06 SHermann73

Our pipeline is also failing with the same error message on BC 20.2.41144.42196. Tested the same code on older version (20.1.39764.41791) it ran fine without an error.

error AL0157: 'CustomControlAddin' is not a valid variable type

carlosyuwono avatar Jun 15 '22 14:06 carlosyuwono

Hello everyone,

Heads up! The hotfix is rolling out right now. The updated version is Platform 20.0.41086.42208.

Best, Nikolay

nndobrev avatar Jun 15 '22 14:06 nndobrev

Hi @nndobrev I can confirm that the mentioned version was rolled out to our environment today and I could successfully install all our extensions again.

SHermann73 avatar Jun 19 '22 13:06 SHermann73

We are happy to hear that @SHermann73. @catadumitru can you please confirm as well in order for us to close this issue.

EmilDamsbo avatar Jun 20 '22 08:06 EmilDamsbo

We fixed the problem before the new version was rolled out marking the problematic procedures as obsolete.

oscarfernandezkurago avatar Jun 20 '22 08:06 oscarfernandezkurago

we also fixed our code by refactoring, so we can trust the test made by @SHermann73

catadumitru avatar Jun 22 '22 13:06 catadumitru