Office.AddinCommands.Event interface

L’objet Event est transmis en tant que paramètre aux fonctions de complément invoquées par les boutons de commande de fonction. L’objet permet au complément d’identifier le bouton sur lequel l’utilisateur a cliqué et de signaler à l’application Office qu’il a terminé son traitement.

Remarques

Pour plus d’informations sur la prise en charge dans Excel, Word et PowerPoint, voir Jeux de conditions requises pour les commandes de complément.

Vous trouverez ci-dessous les informations relatives au support d’Outlook.

Jeu d’API : Boîte aux lettres 1.3

Pour plus d’informations sur la prise en charge, voir Jeux de conditions requises pour les commandes de complément .

Niveau d’autorisation minimal (Outlook) : restreint

Mode Outlook applicable : Rédiger ou Lire

Propriétés

source

Informations sur le contrôle qui a déclenché l’appel de cette fonction.

Méthodes

completed(options)

Indique que le complément a terminé le traitement et sera automatiquement fermé.

Cette méthode doit être appelée à la fin d’une fonction qui a été invoquée par la suivante :

Détails de la propriété

source

Informations sur le contrôle qui a déclenché l’appel de cette fonction.

source:Source;

Valeur de propriété

Remarques

Vous trouverez ci-dessous les informations relatives au support d’Outlook.

Jeu d’API : Boîte aux lettres 1.3

Niveau d’autorisation minimal : restreint

Mode Outlook applicable : Rédiger ou Lire

Exemples

// In this example, consider a button defined in an add-in manifest.
// The following is the XML manifest definition. Below it is the Teams 
// manifest (preview) definition.
//
//<Control xsi:type="Button" id="eventTestButton">
//    <Label resid="eventButtonLabel" />
//    <Tooltip resid="eventButtonTooltip" />
//    <Supertip>
//        <Title resid="eventSuperTipTitle" />
//        <Description resid="eventSuperTipDescription" />
//    </Supertip>
//    <Icon>
//        <bt:Image size="16" resid="blue-icon-16" />
//        <bt:Image size="32" resid="blue-icon-32" />
//        <bt:Image size="80" resid="blue-icon-80" />
//    </Icon>
//    <Action xsi:type="ExecuteFunction">
//        <FunctionName>testEventObject</FunctionName>
//    </Action>
//</Control>
//
// The Teams manifest (preview) definition is the following.
// Ellipses("...") indicate omitted properties.
//
//     "extensions": [
//         {
//             ...
//             "runtimes": [
//                 {
//                  "id": "CommandsRuntime",
//                  "type": "general",
//                  "code": {
//                      "page": "https://localhost:3000/commands.html",
//                      "script": "https://localhost:3000/commands.js"
//                  },
//                  "lifetime": "short",
//                  "actions": [
//                      {
//                          "id": "testEventObject",
//                          "type": "executeFunction",
//                          "displayName": "testEventObject"
//                      }
//                  ]
//              }
//             ],
//             "ribbons": [
//                 {
//                     ...
//                     "tabs": [
//                         ...
//                         "groups": [
//                             ...
//                             "controls": [
//                                 {
//                                      "id": "eventTestButton",
//                                      "type": "button",
//                                      "label": "Perform an action",
//                                      "icons": [
//                                          {
//                                              "size": 16,
//                                              "file": "https://localhost:3000/assets/blue-icon-16.png"
//                                          },
//                                          {
//                                              "size": 32,
//                                              "file": "https://localhost:3000/assets/blue-icon-32.png"
//                                          },
//                                          {
//                                              "size": 80,
//                                              "file": "https://localhost:3000/assets/blue-icon-80.png"
//                                          }
//                                      ],
//                                      "supertip": {
//                                          "title": "Perform an action",
//                                          "description": "Perform an action when clicked."
//                                      },
//                                      "actionId": "testEventObject"
//                                  }
//                             ]
//                         ]
//                     ]                           
//                 }
//             ]
//         }
//     ]



// The button has an id set to "eventTestButton", and will invoke
// the testEventObject function defined in the add-in.
// That function looks like this:
function testEventObject(event) {
    // The event object implements the Event interface.

    // This value will be "eventTestButton".
    const buttonId = event.source.id;

    // Signal to the host app that processing is complete.
    event.completed();
}
// Function is used by two buttons:
// button1 and button2
function multiButton (event) {
    // Check which button was clicked.
    const buttonId = event.source.id;

    if (buttonId === 'button1') {
        doButton1Action();
    } else {
        doButton2Action();
    }

    event.completed();
}

Détails de la méthode

completed(options)

Indique que le complément a terminé le traitement et sera automatiquement fermé.

Cette méthode doit être appelée à la fin d’une fonction qui a été invoquée par la suivante :

completed(options?: EventCompletedOptions): void;

Paramètres

options
Office.AddinCommands.EventCompletedOptions

Facultatif. Dans Outlook, objet qui spécifie le comportement d’un complément à l’envoi, d’un complément de fournisseur de réunion en ligne ou d’un complément mobile de journalisation des notes lorsqu’il termine le traitement d’un événement.

Retours

void

Remarques

Vous trouverez ci-dessous les informations relatives au support d’Outlook.

Jeu d’API : Boîte aux lettres 1.3

Niveau d’autorisation minimal : restreint

Mode Outlook applicable : Rédiger ou Lire

Important:

Exemples

// For the following example, the processItem function is
// defined in the FunctionFile referenced from the add-in manifest,
// and maps to the FunctionName of the action in the associated button control.
function processItem(event) {
    // Do some processing.

    event.completed();
}
// In this example, the checkMessage function was registered as an event handler for ItemSend.
function checkMessage(event) {
    // Get the item being sent.
    const outgoingMsg = Office.context.mailbox.item;

    // Check if subject contains "BLOCK".
    outgoingMsg.subject.getAsync(function (result) {
        // Subject is in `result.value`.
        // If search term "BLOCK" is found, don't send the message.
        const notFound = -1;
        const allowEvent = (result.value.indexOf('BLOCK') === notFound);
        event.completed({ allowEvent: allowEvent });
    });
}