編集

次の方法で共有


Notification.AddAction(Text, Integer, Text) Method

Version: Available or changed with runtime version 1.0.

Specifies an action for the notification.

Syntax

 Notification.AddAction(Caption: Text, CodeunitID: Integer, MethodName: Text)

Parameters

Notification
 Type: Notification
An instance of the Notification data type.

Caption
 Type: Text
The text string that appears as the caption of the action in the notification UI. The string can be a label that is enabled for multilanguage functionality.

CodeunitID
 Type: Integer
The ID of the Codeunit to run when the action is initiated from the notification UI. The codeunit should contain at least one global method to be called by the notification action. The global method must have a Notification data type parameter for accepting the notification object.

MethodName
 Type: Text
The name of the method in the Codeunit, which is specified by the CodeunitID parameter, that you want to run for the action.

Remarks

An action provides a way for you to add an interactive notification that enables users to respond to or take action on the notification. The method that is called by the action contains logic that you want to run for the action.

For more information and a detailed example, see Notifications.

Example

The following code creates two actions for a notification. The actions call the RunAction1 and RunAction2 methods in the codeunit Action Handler.

MyNotification.Message := 'This is a notification';
MyNotification.Scope := NotificationScope::LocalScope;
MyNotification.AddAction('Action 1',Codeunit::"Action Handler",'RunAction1');
MyNotification.AddAction('Action 2',Codeunit::"Action Handler",'RunAction2');
MyNotification.Send();

To handle the actions, the Action Handler codeunit has two global methods that have a Notification data type parameter:

procedure RunAction1(MyNotification : Notification);
begin
    Message('This is RunAction1');
end;

procedure RunAction2(MyNotification : Notification);
begin
    Message('This is RunAction2');
end;

Notification Data Type
Getting Started with AL
Developing Extensions