40
Hello,

Microsoft has created the new ALAppExtensions with a bunch of functions we constantly use. We often create, in our apps, codeunits with helper functions.
When we use these functions, we have to declare somewhere a codeunit variable everywhere and I am proposing here to be able to declare "static" codeunits.

It would be just a compiler trick but the idea would be that:

- Like dotnet.al, we create a file "staticcodeunits.al" where MyHelperCodeunit is given an alias like MyHelper.
- Anywhere in my app, instead of writing :
var
MyHelper: codeunit MyHelperCodeunit;
begin
MyHelper.DoSomething();
end;

It could be written:
begin
MyHelper.DoSomething();
end;

In our apps, we would be able to use functions like Math.Min, Math.Max, StreamHelper.ToBase64() exactly like Dialog.Message or Text.StrSubstNo.
Category: Development
STATUS DETAILS
Needs Votes
Ideas Administrator

Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we might consider it in the future.

Best regards,
Business Central Team

Comments

N

The static functions on enums give an idea of the syntax that could apply: Codeunit::"MyHelpercodeunit".DoSomething()

Category: Development

N

I would like to extend this idea to static procedures and a static property for the Codeunit itself (to be applied to all contained procedures automatically). This would need some more work to differentiate between static/nonstatic functions, but the "only" requirement is to not call/use instance procedures or instance variables in my opinion.

Category: Development