While making our code extensible, we often have to provide new integrationevents to skip normal function logic. We do this by providing OnBefore publishers in the function body.
Similar to how the CRS / waldo codeunit method pattern works (although we don't create method codeunits)
it would be good if we had a code action 'Add OnBeforePublisher' on 'Procedure' level to:
Add a boolean Handled / isHandled variable in the variable section (if var section does not exist, then add),
Create a new IntegrationEvent, named OnBeforeFunctionName
IntegrationEvent should copy all function parameters + add a var parameter for the functions return value + add a var parameter for the Handled boolean
Add a line at the start of the function to call the IntegrationEvent / publishers with all vars + return value + Handled
Add a line : If Handled then exit;
If the functions return value (AccessKey) would not be named, either add a message / alert to first assign a name (preferred). Either add a local variable, that is only used in the exit statement.
internal procedure GetAccessKey() AccessKey: Text
var
Handled: boolean;
AccessKeyNotFoundErr: Label 'Access key not found';
begin
OnBeforeGetAccessKey(AccessKey, Handled);
if Handled then
exit;
if IsNullGuid("Access Key") then
exit('');
....
[IntegrationEvent(false, false)]
local procedure OnBeforeGetAccessKey(var AccessKey: Text; var Handled: boolean)
begin
end;
While making our code extensible, we often have to provide new integrationevents to skip normal function logic. We do this by providing OnBefore publishers in the function body.
Similar to how the CRS / waldo codeunit method pattern works (although we don't create method codeunits)
it would be good if we had a code action 'Add OnBeforePublisher' on 'Procedure' level to:
If the functions return value (AccessKey) would not be named, either add a message / alert to first assign a name (preferred). Either add a local variable, that is only used in the exit statement.