From bb3aa6197053296ac1fad1c6bead043dac86f515 Mon Sep 17 00:00:00 2001 From: Ronny Birkeli Date: Thu, 8 Dec 2022 07:52:37 +0100 Subject: [PATCH] Reload instance to get the latest data elements, including PDF. --- src/Altinn.App.Core/Implementation/DefaultTaskEvents.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Altinn.App.Core/Implementation/DefaultTaskEvents.cs b/src/Altinn.App.Core/Implementation/DefaultTaskEvents.cs index 1802ba15b..c7362bda6 100644 --- a/src/Altinn.App.Core/Implementation/DefaultTaskEvents.cs +++ b/src/Altinn.App.Core/Implementation/DefaultTaskEvents.cs @@ -6,6 +6,7 @@ using Altinn.App.Core.Internal.AppModel; using Altinn.App.Core.Internal.Expressions; using Altinn.App.Core.Internal.Pdf; +using Altinn.App.Core.Models; using Altinn.Platform.Storage.Interface.Models; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -163,7 +164,11 @@ public async Task OnEndProcessTask(string endEvent, Instance instance) } if (_appSettings?.EnableEFormidling == true && _appMetadata.EFormidling?.SendAfterTaskId == endEvent && _eFormidlingService != null) { - await _eFormidlingService.SendEFormidlingShipment(instance); + // The code above updates data elements on the instance. To ensure + // we have the latest instance with all the data elements including pdf, + // we reload the instance before we pass it on to eFormidling. + var updatedInstance = await _instanceClient.GetInstance(instance); + await _eFormidlingService.SendEFormidlingShipment(updatedInstance); } if (_appMetadata.AutoDeleteOnProcessEnd)