Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Note
The AL diagnostics topics are in preview. If you have input for this topic, we'd love to hear from you. Use our GitHub repo to create a PR and add content to this topic by going to here. To read about contributing, see Contribute to the Help. Thanks!
The method '{0}' cannot be used as the implementation for the interface method '{1}' because it has 'OnPrem' scope.
Description
Interface implementations cannot have OnPrem scope because interfaces can be invoked in cloud environments where OnPrem methods are not available.
Remarks
Interface methods can be called from any environment, including cloud (SaaS). A method marked with [Scope('OnPrem')] is only available in on-premises deployments. If such a method implements an interface, calling the interface from a cloud environment would fail at runtime.
How to fix it
Remove the [Scope('OnPrem')] attribute from the implementing method. If the method contains on-premises-only logic, refactor it so the interface implementation works in all environments.
Example of code that triggers AL0922
interface IDataExporter
{
procedure Export(data: Text);
}
codeunit 50100 FileExporter implements IDataExporter
{
// Error: OnPrem method cannot implement an interface method.
[Scope('OnPrem')]
procedure Export(data: Text);
begin
// File I/O that only works on-premises
end;
}
Example of how to fix it
Remove the OnPrem scope and use cloud-compatible APIs, or redesign your feature.
interface IDataExporter
{
procedure Export(data: Text);
}
codeunit 50100 FileExporter implements IDataExporter
{
procedure Export(data: Text);
var
TempBlob: Codeunit "Temp Blob";
begin
// Use cloud-compatible approach
end;
}
Related information
Getting started with AL
Developing extensions
Interfaces in AL