Editar

Partilhar via


IntegrationEvent attribute

Version: Available or changed with runtime version 1.0.

Specifies that the method is published as an integration type event.

Applies to

  • Method

Syntax

[IntegrationEvent(IncludeSender: Boolean, GlobalVarAccess: Boolean [, Isolated: Boolean])]

Arguments

IncludeSender
 Type: Boolean
Specifies whether global methods in the object that contains the event publisher method are exposed to event subscriber methods that subscribe to the event.

GlobalVarAccess
 Type: Boolean
Specifies whether global variables in the object that contains the event publisher method are accessible to event subscriber methods that subscribe to the published event.

[Optional] Isolated
 Type: Boolean
Specifies if event subscribers should be invoked in an isolated transaction.

Snippet support

Typing the shortcut teventint will create the basic IntegrationEvent attribute syntax when using the AL Language extension for Microsoft Dynamics 365 Business Central in Visual Studio Code.

Remarks

When you set the IncludeSender argument to true, the signature of event subscriber methods that subscribe to the published event automatically supports a sender parameter for the published event object, which you must add manually (see the example).

Important

Using GlobalVarAccess will throw a compiler warning, which will become an error in a future release. Instead use the event parameters or mark the page or table variables as protected. For more information, see Protected Variables.

When you set the GlobalVarAccess argument to true, event subscriber methods that subscribe to the event can call the global variable parameters in the object that declares the event publisher method. You must add variable parameters to the event subscriber method signatures manually and use a name and type that matches the variable declaration in the event publisher object (see the example).

For more information about the different event types, see Event Types.

For more information about isolated events, see Isolated Events.

Example

This example publishes an integration type event by using the OnAddressLineChanged method. The method takes a single text data type parameter.

The IncludeSender and GlobalVarAccess arguments are set to true. This means that the signature of event subscriber method SubcribeToOnAddressLineChangedEvent includes:

  • The sender parameter for event publishing codeunit MyPublishingCodeunit.
  • A parameter for the global variable myGlobalVar defined in the publishing codeunit MyPublishingCodeunit.
codeunit 50102 MyPublishingCodeunit
{
    [IntegrationEvent(true, true)]
    procedure OnAddressLineChangedEvent(line : Text[100])
    begin
    end;

    var
        myGlobalVar: Integer;
}

codeunit 50103 MySubscribingCodeunit
{
    [EventSubscriber(ObjectType::Codeunit, Codeunit::MyPublishingCodeunit, 'OnAddressLineChangedEvent', '', true, true)]
    local procedure SubcribeToOnAddressLineChangedEvent(sender: Codeunit MyPublishingCodeunit; myGlobalVar: Integer)
    begin
        // My subscriber code
    end;
}

AL Method Reference
Events in AL
Publishing Events
Raising Events
Subscribing to Events
Isolated Events
Method Attributes