Inconsistent Conversation ID Retrieval in Office JS Using getSelectedItemsAsync

WongYK 5 Reputation points
2025-01-03T08:17:56.9933333+00:00

When using Office.js to retrieve selected items with Office.context.mailbox.getSelectedItemsAsync, the conversationId value returns a string value "[object Object]". However, accessing the conversationId of the same emails through Office.context.mailbox.item.conversationId works as expected and provides the correct conversation ID. This inconsistency poses challenges in processing selected email threads.

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,148 questions
Exchange Server Development
Exchange Server Development
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Development: The process of researching, productizing, and refining new or existing technologies.
560 questions
Microsoft Copilot for Microsoft 365 Development
Microsoft Copilot for Microsoft 365 Development
Microsoft Copilot for Microsoft 365: Microsoft 365 Copilot refers collectively to Copilot experiences within Microsoft 365 applications.Development: The process of researching, productizing, and refining new or existing technologies.
193 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Tasadduq Burney 8,681 Reputation points MVP
    2025-01-03T08:19:59.8033333+00:00

    Check the data returned by getSelectedItemsAsync, Log the conversationId to see its structure. It might be an object, so you may need to dig into its properties

    Office.context.mailbox.getSelectedItemsAsync((result) => {
        if (result.status === Office.AsyncResultStatus.Succeeded) {
            result.value.forEach(item => {
                console.log(item.conversationId); // Check what’s actually being returned
            });
        } else {
            console.error(result.error);
        }
    });
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.