From bca9984c7b910865fada09ee503c30d557dc9c4c Mon Sep 17 00:00:00 2001 From: Stig Killendahl Date: Thu, 4 Jan 2024 10:22:05 +0100 Subject: [PATCH 1/3] Cancel word template merge on --- .../App/Document Sharing/src/DocumentSharing.Table.al | 9 +++++++++ .../Document Sharing/src/DocumentSharingImpl.Codeunit.al | 3 ++- .../App/Word Templates/src/WordTemplateImpl.Codeunit.al | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/System Application/App/Document Sharing/src/DocumentSharing.Table.al b/src/System Application/App/Document Sharing/src/DocumentSharing.Table.al index 9c3c6c07d0..65086d341f 100644 --- a/src/System Application/App/Document Sharing/src/DocumentSharing.Table.al +++ b/src/System Application/App/Document Sharing/src/DocumentSharing.Table.al @@ -121,6 +121,15 @@ table 9560 "Document Sharing" DataClassification = SystemMetadata; InitValue = Ask; } + + /// + /// Specifies whether the action was cancelled. + /// + field(13; Cancelled; Boolean) + { + DataClassification = SystemMetadata; + InitValue = false; + } } keys diff --git a/src/System Application/App/Document Sharing/src/DocumentSharingImpl.Codeunit.al b/src/System Application/App/Document Sharing/src/DocumentSharingImpl.Codeunit.al index e746262114..6ece4d4185 100644 --- a/src/System Application/App/Document Sharing/src/DocumentSharingImpl.Codeunit.al +++ b/src/System Application/App/Document Sharing/src/DocumentSharingImpl.Codeunit.al @@ -134,7 +134,8 @@ codeunit 9561 "Document Sharing Impl." Handled := false; Sleep(2000); // This sleep is to ensure the OneDrive clears the lock on the file after the user saves and closes. DocumentSharingCodeunit.OnGetFileContents(DocumentSharing, Handled); - end; + end else + DocumentSharing.Cancelled := true; Handled := false; DocumentSharingCodeunit.OnDeleteDocument(DocumentSharing, Handled); diff --git a/src/System Application/App/Word Templates/src/WordTemplateImpl.Codeunit.al b/src/System Application/App/Word Templates/src/WordTemplateImpl.Codeunit.al index 40a4811e2d..15997f89cd 100644 --- a/src/System Application/App/Word Templates/src/WordTemplateImpl.Codeunit.al +++ b/src/System Application/App/Word Templates/src/WordTemplateImpl.Codeunit.al @@ -609,6 +609,10 @@ codeunit 9988 "Word Template Impl." TempDocumentSharing.Insert(); DocumentSharing.Share(TempDocumentSharing); + + if TempDocumentSharing.Cancelled then + Error(''); + ResultTempBlob.CreateOutStream(OutStream, TextEncoding::UTF8); TempDocumentSharing.Data.CreateInStream(InStream, TextEncoding::UTF8); CopyStream(OutStream, InStream); From a7edb461031513c95ef5623aed7c0f902c448968 Mon Sep 17 00:00:00 2001 From: Stig <65776111+stkillen@users.noreply.github.com> Date: Thu, 4 Jan 2024 10:43:12 +0100 Subject: [PATCH 2/3] Update src/System Application/App/Document Sharing/src/DocumentSharing.Table.al Co-authored-by: Natalie Karolak <34504100+NKarolak@users.noreply.github.com> --- .../App/Document Sharing/src/DocumentSharing.Table.al | 1 - 1 file changed, 1 deletion(-) diff --git a/src/System Application/App/Document Sharing/src/DocumentSharing.Table.al b/src/System Application/App/Document Sharing/src/DocumentSharing.Table.al index 65086d341f..717bea1f42 100644 --- a/src/System Application/App/Document Sharing/src/DocumentSharing.Table.al +++ b/src/System Application/App/Document Sharing/src/DocumentSharing.Table.al @@ -128,7 +128,6 @@ table 9560 "Document Sharing" field(13; Cancelled; Boolean) { DataClassification = SystemMetadata; - InitValue = false; } } From 852a71a159c09f4e03c88726d155c0d7aac67dd1 Mon Sep 17 00:00:00 2001 From: Stig Killendahl Date: Mon, 15 Apr 2024 15:39:45 +0200 Subject: [PATCH 3/3] Add state enum --- .../App/Document Sharing/app.json | 2 +- .../src/DocumentSharing.Table.al | 5 ++-- .../src/DocumentSharingImpl.Codeunit.al | 2 +- .../src/DocumentSharingState.Enum.al | 30 +++++++++++++++++++ .../src/WordTemplateImpl.Codeunit.al | 2 +- 5 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 src/System Application/App/Document Sharing/src/DocumentSharingState.Enum.al diff --git a/src/System Application/App/Document Sharing/app.json b/src/System Application/App/Document Sharing/app.json index d077688842..3f3d6f47d9 100644 --- a/src/System Application/App/Document Sharing/app.json +++ b/src/System Application/App/Document Sharing/app.json @@ -47,7 +47,7 @@ "idRanges": [ { "from": 9560, - "to": 9562 + "to": 9563 } ], "contextSensitiveHelpUrl": "https://learn.microsoft.com/dynamics365/business-central/" diff --git a/src/System Application/App/Document Sharing/src/DocumentSharing.Table.al b/src/System Application/App/Document Sharing/src/DocumentSharing.Table.al index 717bea1f42..b4fa4be09e 100644 --- a/src/System Application/App/Document Sharing/src/DocumentSharing.Table.al +++ b/src/System Application/App/Document Sharing/src/DocumentSharing.Table.al @@ -123,11 +123,12 @@ table 9560 "Document Sharing" } /// - /// Specifies whether the action was cancelled. + /// Specifies the state of the document sharing operation. /// - field(13; Cancelled; Boolean) + field(13; State; Enum "Document Sharing State") { DataClassification = SystemMetadata; + InitValue = Success; } } diff --git a/src/System Application/App/Document Sharing/src/DocumentSharingImpl.Codeunit.al b/src/System Application/App/Document Sharing/src/DocumentSharingImpl.Codeunit.al index 6ece4d4185..7e95edac40 100644 --- a/src/System Application/App/Document Sharing/src/DocumentSharingImpl.Codeunit.al +++ b/src/System Application/App/Document Sharing/src/DocumentSharingImpl.Codeunit.al @@ -135,7 +135,7 @@ codeunit 9561 "Document Sharing Impl." Sleep(2000); // This sleep is to ensure the OneDrive clears the lock on the file after the user saves and closes. DocumentSharingCodeunit.OnGetFileContents(DocumentSharing, Handled); end else - DocumentSharing.Cancelled := true; + DocumentSharing.State := DocumentSharing.State::Cancelled; Handled := false; DocumentSharingCodeunit.OnDeleteDocument(DocumentSharing, Handled); diff --git a/src/System Application/App/Document Sharing/src/DocumentSharingState.Enum.al b/src/System Application/App/Document Sharing/src/DocumentSharingState.Enum.al new file mode 100644 index 0000000000..4400237e5a --- /dev/null +++ b/src/System Application/App/Document Sharing/src/DocumentSharingState.Enum.al @@ -0,0 +1,30 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace System.Integration; + +/// +/// The result of the sharing operation. +/// +enum 9563 "Document Sharing State" +{ + Extensible = false; + + /// + /// Operation completed successfully. + /// + value(0; Success) + { + Caption = 'Success'; + } + + /// + /// Operation cancelled. + /// + value(1; Cancelled) + { + Caption = 'Cancelled'; + } +} \ No newline at end of file diff --git a/src/System Application/App/Word Templates/src/WordTemplateImpl.Codeunit.al b/src/System Application/App/Word Templates/src/WordTemplateImpl.Codeunit.al index 15997f89cd..aca6724acb 100644 --- a/src/System Application/App/Word Templates/src/WordTemplateImpl.Codeunit.al +++ b/src/System Application/App/Word Templates/src/WordTemplateImpl.Codeunit.al @@ -610,7 +610,7 @@ codeunit 9988 "Word Template Impl." DocumentSharing.Share(TempDocumentSharing); - if TempDocumentSharing.Cancelled then + if TempDocumentSharing.State = TempDocumentSharing.State::Cancelled then Error(''); ResultTempBlob.CreateOutStream(OutStream, TextEncoding::UTF8);