Open krzysztof-plutoflume opened 10 months ago
Hi @krzysztof-plutoflume, thanks for submitting this Outlook question. @samantharamon Could you take a look?
Hi @krzysztof-plutoflume,
Thanks for reaching out. In the file containing your task pane code, you'll need to call Office.context.mailbox.item.getInitializationContextAsync to retrieve the context data you passed to your event handler.
Here's a sample implementation.
Event handler code
...
event.completed(
{
allowEvent: false,
cancelLabel: "Add a location",
commandId: "msgComposeOpenPaneButton",
contextData: JSON.stringify({ a: "aValue", b: "bValue" }),
errorMessage: "Don't forget to add a meeting location.",
sendModeOverride: Office.MailboxEnums.SendModeOverride.PromptUser
}
);
Task pane code
...
Office.context.mailbox.item.getInitializationContextAsync((asyncResult) => {
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
console.log(asyncResult.error.message);
return;
}
const contextData = JSON.parse(asyncResult.value);
console.log(contextData.a);
});
...
I realize that this isn't documented, so I apologize for the inconvenience. I'll get this included in our documentation.
Thanks for your explanation, very clear.
If the task pane with the given commandId is already open when the user clicks Don't Send on the Smart Alerts dialog, is the task pane supposed to receive an updated initialisation context (with the value as set for contextData
in Office.SmartAlertsEventCompletedOptions
)?
At the moment, the initialisation context doesn't seem to be updated, and an already opened task pane isn't reloaded when the user clicks Don't Send.
Is there a reliable way to signal to the task pane that the user clicked Don't Send, so that we can update the contents of the task pane to explain to the user why the email was blocked from sending?
That's a great question. I'm also able to replicate the behavior you're seeing. Let me follow up on this with the team.
Thanks for your patience, @krzysztof-plutoflume. I've confirmed that the contextData
value doesn't currently get updated in the task pane if the pane is already open. I'm assigning this to @besiler to investigate it further.
As a workaround, you could use a SessionData
object to store data that can be accessed from the task pane. For more information, see Office.SessionData.
@samantharamon @exextoc,
Hi both, I wanted to re-raise this issue or at least see what you recommend. In our OnSend event, we are setting some SessionData
that we want displayed in the taskpane when the user clicks "don't send".
In New Outlook for Windows, OWA, Outlook for Mac, and Classic Windows inline messages only - if the task pane is already open, the user tries to send the email again and is blocked again, the task pane is refreshed automatically/reinitialized when they click "Don't send". This works great., our new SessionData
is read and the taskpane accurately reflects what it should.
For Classic Windows, the task pane does not get refreshed automatically for some reason when the email is popped out. I'm wondering if this is a bug? If not, what is your recommendation to ensure the task pane is always using the most updated data from the OnSend event? Do we need to be constantly polling/refreshing the task pane in the background and checking for updated SessionData
?
Thanks for reporting this issue. It has been put on our backlog. We unfortunately have no timelines to share at this point
Internal tracking id: Office: [9148448]
I've got a question regarding the
contextData
member of theOffice.SmartAlertsEventCompletedOptions
interface:How does the add-in receive the context data passed through this option?
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.