{"title":"OnPageBackgroundTaskCompleted (Page) trigger","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/triggers-auto/page/devenv-onpagebackgroundtaskcompleted-page-trigger/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/triggers-auto/page/devenv-onpagebackgroundtaskcompleted-page-trigger, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/triggers-auto/page/devenv-onpagebackgroundtaskcompleted-page-trigger","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Runs after a page background task has successfully completed.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":122,"chars":476},{"level":3,"title":"Parameters","slug":"parameters","at":252,"chars":346},{"level":2,"title":"Remarks","slug":"remarks","at":598,"chars":329},{"level":2,"title":"Example","slug":"example","at":927,"chars":1007},{"level":2,"title":"Related information","slug":"related-information","at":1934,"chars":249}],"text":"> Version: _Available or changed with runtime version 4.0._\nRuns after a page background task has successfully completed.\n## Syntax\n```al\ntrigger OnPageBackgroundTaskCompleted(TaskId: Integer; Results: Dictionary of [Text,Text])\nbegin\n    ...\nend;\n```\n### Parameters\nTaskId\nType: ../../methods-auto/integer/integer-data-type\nSpecifies the ID of the background task that was run. The ID is automatically assigned to the background task when it is created.\nResults\nType: Dictionary of [Text,Text]<../../methods-auto/dictionary/dictionary-data-type>\nSpecifies the results of the page background task.\n## Remarks\nThe callback triggers can't execute UI operations, except notifications and control updates. This means that, for example, CurrPage.Update() statements are ignored because they would in many cases lead to infinite loops when page background tasks are started from the devenv-onaftergetcurrrecord-page-trigger trigger.\n## Example\nThe following example modifies the OnPageBackgroundTaskCompleted trigger to update the page with the started and finished times that were calculated in the page background task, and displays a notification that the times have been updated. For more details about this example, see ../../devenv-page-background-tasks.\n```al\n    trigger OnPageBackgroundTaskCompleted(TaskId: Integer; Results: Dictionary of [Text, Text])\n    var\n        started: Text;\n        waited: Text;\n        finished: Text;\n        PBTNotification: Notification;\n    begin\n        if (TaskId = WaitTaskId) then begin\n            Evaluate(started, Results.Get('started'));\n            Evaluate(waited, Results.Get('waited'));\n            Evaluate(finished, Results.Get('finished'));\n\n            before1 := started;\n            duration1 := waited;\n            after1 := finished;\n            PBTNotification.Message('Start and finish times have been updated.');\n            PBTNotification.Send();\n        end;\n    end;\n```\n## Related information\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>\nOnPageBackgroundTaskCompleted (Page Extension) Trigger<../pageextension/devenv-onpagebackgroundtaskcompleted-pageextension-trigger>"}