【问题标题】:Office.js appointment is still marked as changed in saveAsync callbackOffice.js 约会在 saveAsync 回调中仍标记为已更改
【发布时间】:2018-08-08 01:10:09
【问题描述】:

我使用 Office javascript API 来构建 Outlook 加载项。我对保存约会然后关闭约会窗口的一些代码有疑问。我希望通过 API 保存约会后没有未保存的更改,但是在运行代码后我仍然得到“放弃更改”确认对话框。仅在编辑现有约会以及在保存之前向约会添加自定义属性时才会出现此问题。

这是我的(打字稿)代码的重要部分:

private saveAppointmentAndSetProperty(appointment: any): Observable<any> {
    const subject = new Subject<any>();

Office.context.mailbox.item.loadCustomPropertiesAsync(
        result => {
            if (this.isErrorResult(result)) {
                subject.error(result.error.message);
            } else {
                const properties = result.value;
                properties.set('MY_PROPERTY', true);
                this.saveCustomProperties(properties, subject,
                    () => this.saveAppointment(appointment, subject));
            }
        }
    );

    return subject;
}

private saveCustomProperties(properties: any, subject: Subject<any>, callback: () => void): void {
    properties.saveAsync(result => {
        if (this.isErrorResult(result)) {
            subject.error(result.error.message);
        } else {
            callback();
        }
    });
}

private saveAppointment(appointment: any, subject: Subject<any>): void {
    appointment.saveAsync((asyncResult) => {
        if (this.isErrorResult(asyncResult)) {
            subject.error(asyncResult.error.message);
        } else {
            appointment.close();

            subject.next(asyncResult.value);
            subject.complete();
        }
    });
}

saveAppointmentAndSetProperty() 是代码的入口。如果我改为在 saveAppointment 中执行代码,我看不到任何问题。

【问题讨论】:

    标签: api typescript outlook-addin office-js


    【解决方案1】:

    这是 OWA 中 item.saveAsync 的一个已知问题。重现问题需要满足以下条件:

    1. 必须是现有约会
    2. 约会必须有参加者

    item.saveAsync() 将返回正确的项目 ID,但不会将撰写表单中的更改保留到服务并清除脏状态。

    保存自定义属性应将属性保存到服务。如果您不依赖对撰写表单进行额外更改(例如更改正文、主题、位置、与会者等)的 API ) 对于与与会者的现有约会,您可以在 CustomProperties 上调用 saveAsync。假设您之后不调用item.saveAsync(),这将保留对服务的自定义属性的更改,而不显示丢弃更改的对话框。

    【讨论】:

    • 感谢您的回答。是否有错误报告可以在问题得到解决时通知我?我必须调用 item.saveAsync,因为我需要在项目上设置 itemId(它不是在调用 saveAsync() 之前)
    • 我们内部积压中正在跟踪这个错误,目前我们没有公开这个。
    猜你喜欢
    • 2017-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-27
    • 2021-05-16
    • 1970-01-01
    相关资源
    最近更新 更多