Muokkaa

Jaa


Page.SetBackgroundTaskResult(Dictionary of [Text, Text]) Method

Version: Available or changed with runtime version 4.0.

Sets the page background task result as a dictionary. When the task is completed, the OnPageBackgroundCompleted trigger will be invoked on the page with this result dictionary.

Syntax

 Page.SetBackgroundTaskResult(Results: Dictionary of [Text, Text])

Parameters

Results
 Type: Dictionary of [Text, Text]
Specifies the dictionary of results for the page background task.

Remarks

You use this method in a page background task codeunit to pass the results of the page background task codeunit to the calling page. Before calling this method, use the Add method to populate the Results dictionary with the key-value pairs that you want to pass to calling page's OnPageBackgroundTaskCompleted trigger. The OnPageBackgroundCompleted trigger can then handle the results on the calling page, such as updating the record in the UI or database.

Example

The following code is an example of a page background task codeunit that uses the SetBackgroundTaskResult method to set a dictionary of results that will be passed to the calling page. For more details about this example, see Page Background Tasks.

codeunit 50100 PBTWaitCodeunit
{
    trigger OnRun()
    var
        Result: Dictionary of [Text, Text];
        StartTime: Time;
        WaitParam: Text;
        WaitTime: Integer;
        EndTime: Time;
    begin
        if not Evaluate(WaitTime, Page.GetBackgroundParameters().Get('Wait')) then
            Error('Could not parse parameter WaitParam');

        StartTime := System.Time();
        Sleep(WaitTime);
        EndTime := System.Time();

        Result.Add('started', Format(StartTime));
        Result.Add('waited', Format(WaitTime));
        Result.Add('finished', Format(EndTime));

        Page.SetBackgroundTaskResult(Result);
    end;
}

Page Background Tasks
Page Data Type
Get Started with AL
Developing Extensions