Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistent sessionData.getAllAsync return value #5353

Open
b-tosic opened this issue Jan 30, 2025 · 3 comments
Open

inconsistent sessionData.getAllAsync return value #5353

b-tosic opened this issue Jan 30, 2025 · 3 comments
Assignees
Labels
Area: Outlook Issue related to Outlook add-ins Status: in backlog Issue is being tracked in the backlog but timeline for resolution is unknown Type: product bug Bug in the Office Add-ins platform or Office JavaScript APIs

Comments

@b-tosic
Copy link

b-tosic commented Jan 30, 2025

Hello,

Is sessionData.getAllAsync supposed to return a dictionary?
At least documentation is not clear https://learn.microsoft.com/en-us/javascript/api/outlook/office.sessiondata?view=outlook-js-preview#outlook-office-sessiondata-getallasync-member(1)

it states: "Gets all session data key-value pairs."

It seems that when sessionData is empty it returns string '{}' (not an dictionary object).

Here is a code snippet to reproduce the issue:
`
Office.context.mailbox.item.sessionData.getAllAsync((asyncRes1)=>{
let allData1 = asyncRes1.value;
let type1 = typeof allData1; // 'string' <-- we got a string '{}' not an empty dictionary object

Office.context.mailbox.item.sessionData.setAsync("something123", "someval1", (asyncRes2)=>{
    Office.context.mailbox.item.sessionData.getAllAsync((asyncRes3)=>{
      let allData2 = asyncRes3.value;
      let type2 = typeof allData2; // 'object'  <--now we get dictionary

      Office.context.mailbox.item.sessionData.removeAsync("something123", (asyncRes4)=>{
              Office.context.mailbox.item.sessionData.getAllAsync((asyncRes5)=>{
                let allData3 = asyncRes5.value;
                let type3 = typeof allData3; // 'string'    <-- again when it is empty we got a string
              }); 
          });
    }); 
});

});
`

I'm running this in Outlook taskpane in Compose window.

Or should I do some initialization so that sessionData is always initialized to object.
Please advise.

Kind Regards,
Bojan

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP label Jan 30, 2025
@b-tosic
Copy link
Author

b-tosic commented Jan 30, 2025

I apologize, but for some reason code formatting doesn't want to format code snippet correctly in my question above (it did not format first 3 lines as code).

@AlexJerabek
Copy link
Collaborator

Thanks for raising this question @b-tosic.

@samantharamon, could you please take a look?

@AlexJerabek AlexJerabek added Area: Outlook Issue related to Outlook add-ins Needs: attention 👋 Waiting on Microsoft to provide feedback Type: discussion and removed Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP labels Jan 30, 2025
@samantharamon samantharamon added Type: product bug Bug in the Office Add-ins platform or Office JavaScript APIs Status: in backlog Issue is being tracked in the backlog but timeline for resolution is unknown and removed Type: discussion Needs: attention 👋 Waiting on Microsoft to provide feedback labels Feb 4, 2025
@samantharamon samantharamon transferred this issue from OfficeDev/office-js-docs-reference Feb 4, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP label Feb 4, 2025
@samantharamon samantharamon removed the Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP label Feb 4, 2025
@exextoc exextoc added the Needs: attention 👋 Waiting on Microsoft to provide feedback label Feb 4, 2025
@samantharamon
Copy link

Hi @b-tosic,

Thanks for reporting this behavior. The getAllAsync method should return a dictionary object, so when no session data is set on the item, the call should return an empty object (Outlook on the web returns this type correctly). This bug in classic Outlook on Windows is currently being tracked in our internal backlog using the internal reference number 9768247. We'll update this post once the issue has been resolved.

@samantharamon samantharamon removed the Needs: attention 👋 Waiting on Microsoft to provide feedback label Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Outlook Issue related to Outlook add-ins Status: in backlog Issue is being tracked in the backlog but timeline for resolution is unknown Type: product bug Bug in the Office Add-ins platform or Office JavaScript APIs
Projects
None yet
Development

No branches or pull requests

4 participants