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

Can I set identifiers immutable in office.js by adding `Prefer: IdType="ImmutableId" `in header?


Problem

In office.js identifiers are mutable .They always changes if email changed its location(from Draft to Sent e.tc ).I want to use for my add-in identifiers what are immutable.

In Graph api

In graph.api you can use immutable identifiers link to allow them "work" need to add header to REST calls (header is Prefer: IdType="ImmutableId")

So question is

Can I set same header(Prefer: IdType="ImmutableId") to office.js ?Using for that Office.InternetHeaders.setAsync() method to make identifiers immutable?


Solution

  • No. internetHeaders.SetAsync(). is used to set the internetHeaders of the Outgoing mail.

    The instructions you referenced to add Prefer: IdType="ImmutableId" is referring to the headers when you make a REST call, and does not releate to office.js apis.

    Immutable IDs do not work with any office.js apis. The only itemID available is the EWSId via Office.context.mailbox.item.itemId. However, as you noted the EWSId will change if the item switches folders.

    You may be able to use Graph/REST to translate the EWSId into immutable: https://learn.microsoft.com/en-us/graph/api/user-translateexchangeids?view=graph-rest-1.0&tabs=http

    But Office.js inputs/outputs are always EWSId's in the function.