OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
670 stars 96 forks source link

Error is thrown when trying to save to custom properties during initialization in New Outlook for Windows. #4851

Closed ricardoleonhart closed 4 days ago

ricardoleonhart commented 2 weeks ago

After my add-in is loaded, it will immediately load the custom properties, set a property and save it. If I open New Outlook for Windows and launch my add-in, the saving part will fail.

Your Environment

Additional info:

Expected behavior

Saving to custom properties is successfull upon initialization of add-in and custom properties.

Current behavior

Saving to custom properties is failing after initialization of custom properties.

Steps to reproduce

  1. Create a default React and Typescript Outlook add-in using Yeoman generator
  2. Add these code to src\taskpane\index.tsx at line 15 (immediately after Office.onReady

    console.log("on ready");
    console.log("start loading custom props");
    const getCustomProperties = new Promise<Office.CustomProperties>((resolve, reject) => {
    Office?.context?.mailbox?.item?.loadCustomPropertiesAsync((result) => {
      if (result.status === Office.AsyncResultStatus.Failed) {
        console.log("failed to load custom properties");
        reject(result.error);
      }
      console.log("load successfully");
      resolve(result.value);
    });
    });
    
    const customProperties = await getCustomProperties;
    
    customProperties.set("test", "true");
    customProperties.saveAsync((asyncResult) => {
    console.log(asyncResult.status);
    if (asyncResult.status === Office.AsyncResultStatus.Failed) {
      console.error(asyncResult.error);
    }
    });
  3. build (I use pnpm build)
  4. Deploy the add-in dist files to server.
  5. Deploy the add-in manifest via Outlook admin
  6. Open New Outlook for Windows via powershell command olk.exe --devtools
  7. Quickly create a new message and launch the add-in
  8. Observe the error in console logs.

Context

My add-in needs to initialize and store the some data immediately in a persistent storage after it is loaded. AFAIK, custom properties is the best for this. This issue will cause my add-in to unable to perform its tasks because the initial data are not being set properly.

Useful logs

Network log of the issue image

Console logs image

mobisw-msft commented 2 weeks ago

Hey @ricardoleonhart ,

Is this issue only happening the first time an add-in tries to set Custom properties in a new session? More specifically, can you confirm if #4628 is the same as the issue that you are reporting?

ricardoleonhart commented 2 weeks ago

Hi @mobisw-msft , yes that seems to be the same issue. Thanks!

rkpathak commented 1 week ago

Marking as duplicate, please refer to the https://github.com/OfficeDev/office-js/issues/4628 for backlog updates.

microsoft-github-policy-service[bot] commented 4 days ago

This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!