{"title":"OnPageBackgroundTaskError (Page) trigger","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/triggers-auto/page/devenv-onpagebackgroundtaskerror-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-onpagebackgroundtaskerror-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-onpagebackgroundtaskerror-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 when an error occurs in a page background task.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":113,"chars":794},{"level":3,"title":"Parameters","slug":"parameters","at":283,"chars":624},{"level":2,"title":"Example","slug":"example","at":907,"chars":1007},{"level":2,"title":"Related information","slug":"related-information","at":1914,"chars":241}],"text":"> Version: _Available or changed with runtime version 4.0._\nRuns when an error occurs in a page background task.\n## Syntax\n```al\ntrigger OnPageBackgroundTaskError(TaskId: Integer; ErrorCode: Text; ErrorText: Text; ErrorCallStack: Text; var IsHandled: Boolean)\nbegin\n    ...\nend;\n```\n### Parameters\nTaskId\nType: ../../methods-auto/integer/integer-data-type\nSpecifies the ID of the background task that was run.\nErrorCode\nType: ../../methods-auto/text/text-data-type\nSpecifies the severity level of the error that occurred.\nErrorText\nType: ../../methods-auto/text/text-data-type\nSpecifies the message that explains the error that occurred.\nErrorCallStack\nType: ../../methods-auto/text/text-data-type\nSpecifies the call stack for the error that occurred.\nIsHandled\nType: ../../methods-auto/boolean/boolean-data-type\ntrue indicates that the error has been handled; false indicates that it has not been handled.\n## Example\nThe following example modifies the OnPageBackgroundTaskError trigger to display a more user-friendly notification in the client when the error `Could not parse parameter WaitParam` or timeout occurs in the page background task. For more details about this example, see ../../devenv-page-background-tasks.\n```al\ntrigger OnPageBackgroundTaskError(TaskId: Integer; ErrorCode: Text; ErrorText: Text; ErrorCallStack: Text; var IsHandled: Boolean)\nvar\n    PBTErrorNotification: Notification;\nbegin\n    if (ErrorText = 'Could not parse parameter WaitParam') then begin\n        IsHandled := true;\n    PBTErrorNotification.Message('Something went wrong. The start and finish times have been updated.');\n    PBTErrorNotification.Send();\n    end\n\n    else if (ErrorText = 'Child Session task was terminated because of a timeout.') then begin\n        IsHandled := true;\n        PBTErrorNotification.Message('It took to long to get results. Try again.');\n        PBTErrorNotification.Send();\n    end\nend;\n```\n## Related information\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>\nOnPageBackgroundTaskError (Page Extension) Trigger<../pageextension/devenv-onpagebackgroundtaskerror-pageextension-trigger>"}