Search code examples
outlookoffice-jsoutlook-addinoffice-addinsoutlook-web-addins

Office.js callback for timeout events


We are using ExecuteFunction to call functions in our Add-In one a button click.

We are facing the issue that it's possible that the function takes more than 5min to execute. Which seems to be the hard timeout limit.

Is there a way to get at least notified about the timeout in a callback or something?

// Commands.js:
const replyAction = async (event: Office.AddinCommands.Event) => {
    // Long running code
    ...

    event.completed(). // this never gets called
}

window.replyAction = replyAction;
// manifest.xml
<Action xsi:type="ExecuteFunction">
   <FunctionName>composeAction</FunctionName>
</Action>

Solution

  • Is there a way to get at least notified about the timeout in a callback or something?

    The Office JavaScript API doesn't provide anything for that out of the box. You can use your own timer to calculate the timeout, see How to create an accurate timer in javascript? for more information.

    Note, you can post or vote for an existing feature request on Tech Community where they are considered when the Office dev team goes through the planning process.

    // Long running code

    If your long-running code is related to extracting the data from Office/Outlook you may consider using the launch event for pre-fetching the required data if required. See Configure your Outlook add-in for event-based activation for more information.

    Also you may consider opening a task pane instead of executing a function. In case of task pane you may run a time-consuming functions without issues.