Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ControlAddIn/usercontrol in page loses its actual type when referenced in a pageextension, breaking passing to procs #7107

Closed
dzzzb opened this issue Jul 6, 2022 · 3 comments
Labels
accepted al-core-compiler al-language ships-in-future-update The issue is fixed in our 'master' branch and will ship in the next PREVIEW release

Comments

@dzzzb
Copy link

dzzzb commented Jul 6, 2022

If we have a base page that declares a usercontrol of a specific ControlAddIn type, and in a pageextension we try to use that control e.g. to pass it to a function expecting a ControlAddIn of that type - this is broken. The pageextension loses the actual type.


This code:

pageextension 50100 TestPageExtension extends "Accountant Activities"
{
    procedure Test()
    begin
        TestCodeunitProcedure(CurrPage.SATAsyncLoader);
    end;

    procedure TestCodeunitProcedure(SATASyncLoader: ControlAddIn SatisfactionSurveyAsync)
    begin
    end;
}

Gives this error:

image

Of which full copy:

[{
	"resource": "/c:/Users/daniel.boles/Documents/AL/UserControlType1/HelloWorld.al",
	"owner": "_generated_diagnostic_collection_name_#0",
	"code": {
		"value": "AL0133",
		"target": {
			"$mid": 1,
			"external": "https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/diagnostics/diagnostic-al133",
			"path": "/en-us/dynamics365/business-central/dev-itpro/developer/diagnostics/diagnostic-al133",
			"scheme": "https",
			"authority": "docs.microsoft.com"
		}
	},
	"severity": 8,
	"message": "Argument 1: cannot convert from 'UserControl SATAsyncLoader' to 'ControlAddIn SatisfactionSurveyAsync'",
	"source": "AL",
	"startLineNumber": 5,
	"startColumn": 31,
	"endLineNumber": 5,
	"endColumn": 54
}]

Shouldn't this Just Work, i.e. code in the pageextension should have access to the usercontrol/ControlAddIn with its real type? Rather than only knowing it's some kind of usercontrol but not being able to do anything much with it.

Thanks!


Name: AL Language
Id: ms-dynamics-smb.al
Description: AL development tools for Dynamics 365 Business Central
Version: 9.2.639332
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-dynamics-smb.al
@thpeder
Copy link
Member

thpeder commented Aug 30, 2022

This is fix and will be released in a future update.
Please note that the fix requires new symbols built with the updated compiler, which means that a server update with the updated compiler is needed for this to work, so simply getting the update for the AL language on Visual Studio Code is not enough.

@dzzzb
Copy link
Author

dzzzb commented Aug 30, 2022

Brilliant, thanks!

@BazookaMusic
Copy link

A correction on what Thomas said, unfortunately we do not want to expose access to Control Add-Ins from other extensions for security reasons. There will be a deprecation notice on this.

A workaround if you own the base object is to add a procedure on the page to make the changes you want to the page. If the control add-in is on a microsoft page, then access will need to be exposed through an event.

@JesperSchulz JesperSchulz added the ships-in-future-update The issue is fixed in our 'master' branch and will ship in the next PREVIEW release label Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted al-core-compiler al-language ships-in-future-update The issue is fixed in our 'master' branch and will ship in the next PREVIEW release
Projects
None yet
Development

No branches or pull requests

5 participants