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
677 stars 95 forks source link

Office.context.mailbox.item properties are null in Desktop version for recurring events #4703

Closed ystvan closed 3 months ago

ystvan commented 3 months ago

Provide required information needed to triage your issue

An Outlook office web add-in has a pure JavaScript that works differently in Windows Desktop and Web for Outlook Calendar Recurring events that happens in the future. Single instances are never an issue.

 await Office.onReady();

 const item = Office.context.mailbox.item;

the item for web is

image

the same item for Desktop is (using olk.exe --devtools according to source in Microsoft Learn)

image

Your Environment

Expected behavior

The itemproperties are not null for Desktop Version.

Current behavior

Some properties are null of item

Steps to reproduce

Link to live example(s)




Provide additional details




Context

Useful logs

Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.

neprasad-microsoft commented 3 months ago

Hi @ystvan We tried to repro this on Outlook on the Web/New Outlook and Legacy Outlook on Windows but could not reproduce this issue. We tested by checking the Office.context.mailbox.item properties on a recurring event in the future. Could you share your add-in manifest? Which property do you see as null? On which platform do you see this issue - Legacy Outlook or New Outlook? Please collect the log files and share with us - https://github.com/OfficeDev/office-js/wiki/Collecting-log-files-for-Outlook-Add%E2%80%90ins-issues

You can share files in a private repo and give access to exextoc.

ystvan commented 3 months ago

Sure thing, before I share my manifest xml, is it OK to obfuscate some values like URLs?

ystvan commented 3 months ago

Hi @ystvan We tried to repro this on Outlook on the Web/New Outlook and Legacy Outlook on Windows but could not reproduce this issue. We tested by checking the Office.context.mailbox.item properties on a recurring event in the future. Could you share your add-in manifest? Which property do you see as null? On which platform do you see this issue - Legacy Outlook or New Outlook? Please collect the log files and share with us - https://github.com/OfficeDev/office-js/wiki/Collecting-log-files-for-Outlook-Add%E2%80%90ins-issues

You can share files in a private repo and give access to exextoc.

<?xml version="1.0" encoding="UTF-8"?> <OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0" xsi:type="MailApp">

<!-- Begin Basic Settings: Add-in metadata, used for all versions of Office unless override provided. -->

<!-- IMPORTANT! Id must be unique for your add-in, if you reuse this manifest ensure that you change this id to a new GUID. -->
<Id>00000000-0000-0000-0000-000000000000</Id>

<!--Version. Updates from the store only get triggered if there is a version change. -->
<Version>2.0.0.2</Version>
<ProviderName>Lorem ipsum</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<!-- The display name of your add-in. Used on the store and various places of the Office UI such as the add-ins dialog. -->
<DisplayName DefaultValue="Lorem ipsum" />

<Description DefaultValue="Lorem ipsum">
    <Override Locale="da-DK" Value="Lorem ipsum" />
    <Override Locale="de-DE" Value="Lorem ipsum" />
    <Override Locale="sv-SE" Value="Lorem ipsum" />
    <Override Locale="no-NO" Value="Lorem ipsum" />
</Description>

<!-- Icon for your add-in. Used on installation screens and the add-ins dialog. -->
<IconUrl DefaultValue="https://lorem.ipsum.net/icon-64.png"/>
<HighResolutionIconUrl DefaultValue="https://lorem.ipsum.net/icon-128.png"/>

<!--If you plan to submit this add-in to the Office Store, uncomment the SupportUrl element below-->
<SupportUrl DefaultValue="https://lorem.ipsum.net/" />

<!-- Domains that will be allowed when navigating. For example, if you use ShowTaskpane and then have an href link, navigation will only be allowed if the domain is on this list. -->
<AppDomains>
    <AppDomain>https://lorem.ipsum.net/</AppDomain>
    <AppDomain>https://login.microsoftonline.com/</AppDomain>
    <AppDomain>https://login.microsoftonline.com/common</AppDomain>
    <AppDomain>https://login.microsoftonline.com/common/oauth2/</AppDomain>
    <AppDomain>https://login.microsoftonline.com/common/oauth2/v2.0/</AppDomain>
    <AppDomain>https://login.microsoftonline.com/common/oauth2/v2.0/authorize/</AppDomain>
</AppDomains>
<!--End Basic Settings. -->

<Hosts>
    <Host Name="Mailbox" />
</Hosts>
<Requirements>
    <Sets>
        <Set Name="Mailbox" MinVersion="1.1" />
    </Sets>
</Requirements>
<FormSettings>
    <Form xsi:type="ItemRead">
        <DesktopSettings>
            <SourceLocation DefaultValue="https://lorem.ipsum.net/"/>
            <RequestedHeight>250</RequestedHeight>
        </DesktopSettings>
    </Form>
</FormSettings>

<Permissions>ReadWriteItem</Permissions>
<Rule xsi:type="RuleCollection" Mode="Or">
    <Rule xsi:type="ItemIs" ItemType="Message" FormType="Read"/>
    <Rule xsi:type="ItemIs" ItemType="Appointment" FormType="Read"/>
</Rule>
<DisableEntityHighlighting>false</DisableEntityHighlighting>

<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
    <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1">

        <Requirements>
            <bt:Sets DefaultMinVersion="1.3">
                <bt:Set Name="Mailbox" />
            </bt:Sets>
        </Requirements>
        <Hosts>
            <Host xsi:type="MailHost">

                <DesktopFormFactor>
                    <!-- Event Read -->
                    <ExtensionPoint xsi:type="AppointmentOrganizerCommandSurface">
                        <OfficeTab id="TabDefault">
                            <Group id="CategoriesGroupAppointmentOrganizer">
                                <Label resid="CategoriesGroupLabel"/>
                                <Control xsi:type="Button" id="AppointmentOrganizerSelectButton">
                                    <Label resid="SelectButtonLabel"/>
                                    <Supertip>
                                        <Title resid="SelectButtonLabel"/>
                                        <Description resid="SelectButtonDescription"/>
                                    </Supertip>
                                    <Icon>
                                        <bt:Image size="16" resid="icon16" />
                                        <bt:Image size="32" resid="icon32" />
                                        <bt:Image size="80" resid="icon80" />
                                    </Icon>
                                    <Action xsi:type="ShowTaskpane">
                                        <SourceLocation resid="showTaskpaneUrl"/>
                                    </Action>
                                </Control>
                            </Group>
                        </OfficeTab>
                    </ExtensionPoint>
                    <ExtensionPoint xsi:type="AppointmentAttendeeCommandSurface">
                        <OfficeTab id="TabDefault">
                            <Group id="CategoriesGroupAttendeeOrganizer">
                                <Label resid="CategoriesGroupLabel" />
                                <Control xsi:type="Button" id="AppointmentAttendeeSelectButton">
                                    <Label resid="SelectButtonLabel" />
                                    <Supertip>
                                        <Title resid="SelectButtonLabel" />
                                        <Description resid="SelectButtonDescription" />
                                    </Supertip>
                                    <Icon>
                                        <bt:Image size="16" resid="icon16" />
                                        <bt:Image size="32" resid="icon32" />
                                        <bt:Image size="80" resid="icon80" />
                                    </Icon>
                                    <Action xsi:type="ShowTaskpane">
                                        <SourceLocation resid="showTaskpaneUrl" />
                                    </Action>
                                </Control>
                            </Group>
                        </OfficeTab>
                    </ExtensionPoint>
                </DesktopFormFactor>
            </Host>
        </Hosts>
        <Resources>
            <bt:Images>
                <bt:Image id="icon16" DefaultValue="https://lorem.ipsum.net/Icon-16.png"/>
                <bt:Image id="icon32" DefaultValue="https://lorem.ipsum.net/Icon-32.png"/>
                <bt:Image id="icon80" DefaultValue="https://lorem.ipsum.net/Icon-80.png"/>
            </bt:Images>
            <bt:Urls>
                <bt:Url id="showTaskpaneUrl" DefaultValue="https://lorem.ipsum.net/"/>
            </bt:Urls>
            <bt:ShortStrings>
                <bt:String id="CategoriesGroupLabel" DefaultValue="Lorem ipsum"/>
                <bt:String id="SelectButtonLabel" DefaultValue="Lorem ipsum">
                    <bt:Override Locale="da-DK" Value="Lorem ipsum" />
                    <bt:Override Locale="ge-GE" Value="Lorem ipsum" />
                    <bt:Override Locale="sv-SE" Value="Lorem ipsum" />
                    <bt:Override Locale="no-NO" Value="Lorem ipsum" />
                </bt:String>
            </bt:ShortStrings>
            <bt:LongStrings>
                <bt:String id="SelectButtonDescription" DefaultValue="Lorem ipsum">
                    <bt:Override Locale="da-DK" Value="Lorem ipsum" />
                    <bt:Override Locale="ge-GE" Value="Lorem ipsum" />
                    <bt:Override Locale="sv-SE" Value="Lorem ipsum" />
                    <bt:Override Locale="no-NO" Value="Lorem ipsum" />
                </bt:String>
            </bt:LongStrings>
        </Resources>
        <WebApplicationInfo>
            <Id>00000000-0000-0000-0000-000000000000</Id>
            <Resource>api://lorem.ipsum.net/00000000-0000-0000-0000-000000000000</Resource>
            <Scopes>
                <Scope>openid</Scope>
                <Scope>user.read</Scope>
                <Scope>calendars.read</Scope>
                <Scope>profile</Scope>
            </Scopes>
        </WebApplicationInfo>
    </VersionOverrides>
</VersionOverrides>

ystvan commented 3 months ago

Which property do you see as null?

everything is null, except two properties: itemType and seriesId

On which platform do you see this issue - Legacy Outlook or New Outlook?

New outlook

ystvan commented 3 months ago

@neprasad-microsoft @exextoc shared a repro https://github.com/ystvan/OutlookRepro

Single event works

image

Recurring event from Outlook Web

image

Recurring event from Outlook Windows Desktop (New not Legacy)

Notice all the missing properties

Repro steps

  1. Create a recurring event for next week, daily occurrences running for 2 weeks
  2. Open the web add in when selecting an occurrence
  3. See debug point on itemafter Office.onReady

image

neprasad-microsoft commented 3 months ago

Hi @ystvan This is happening because in Monarch the item opens in edit mode and in OWA the item opens in Read mode. Both of these have different set of APIs and properties on item. This is expected behaviour.

ystvan commented 3 months ago

@neprasad-microsoft

This is happening because in Monarch the item opens in edit mode and in OWA the item ope

What is Monarch? Can I change the behaviour? Can I open in Monarch in read mode? Can you please point me to a documentation where can I read upon it?

ystvan commented 3 months ago

@neprasad-microsoft Is there any kind of item in Monarch that holds the information I need

neprasad-microsoft commented 3 months ago

Hi @ystvan All of these will be available as async properties on the appointment compose surface - https://learn.microsoft.com/en-us/javascript/api/outlook/office.appointmentcompose For example to get the subject you can write something like this - Office.context.mailbox.item.subject.getAsync((result) => { if (result.status !== Office.AsyncResultStatus.Succeeded) { console.error(Action failed with message ${result.error.message}); return; } console.log(Subject: ${result.value}); }); Copied from - https://learn.microsoft.com/en-us/javascript/api/outlook/office.appointmentcompose?view=outlook-js-preview#outlook-office-appointmentcompose-subject-member

ystvan commented 3 months ago

@neprasad-microsoft Appreciate the sources for the documentation. Thank you, it worked!