# OnPageBackgroundTaskError (Page) trigger
> Version: _Available or changed with runtime version 4.0._
Runs when an error occurs in a page background task.
## Syntax
```al
trigger OnPageBackgroundTaskError(TaskId: Integer; ErrorCode: Text; ErrorText: Text; ErrorCallStack: Text; var IsHandled: Boolean)
begin
    ...
end;
```
### Parameters
TaskId
Type: ../../methods-auto/integer/integer-data-type
Specifies the ID of the background task that was run.
ErrorCode
Type: ../../methods-auto/text/text-data-type
Specifies the severity level of the error that occurred.
ErrorText
Type: ../../methods-auto/text/text-data-type
Specifies the message that explains the error that occurred.
ErrorCallStack
Type: ../../methods-auto/text/text-data-type
Specifies the call stack for the error that occurred.
IsHandled
Type: ../../methods-auto/boolean/boolean-data-type
true indicates that the error has been handled; false indicates that it has not been handled.
## Example
The 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.
```al
trigger OnPageBackgroundTaskError(TaskId: Integer; ErrorCode: Text; ErrorText: Text; ErrorCallStack: Text; var IsHandled: Boolean)
var
    PBTErrorNotification: Notification;
begin
    if (ErrorText = 'Could not parse parameter WaitParam') then begin
        IsHandled := true;
    PBTErrorNotification.Message('Something went wrong. The start and finish times have been updated.');
    PBTErrorNotification.Send();
    end

    else if (ErrorText = 'Child Session task was terminated because of a timeout.') then begin
        IsHandled := true;
        PBTErrorNotification.Message('It took to long to get results. Try again.');
        PBTErrorNotification.Send();
    end
end;
```
## Related information
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>
OnPageBackgroundTaskError (Page Extension) Trigger<../pageextension/devenv-onpagebackgroundtaskerror-pageextension-trigger>

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. https://jonas-paprotka.de/docs/dev-itpro/developer/triggers-auto/page/devenv-onpagebackgroundtaskerror-page-trigger/
