編輯

共用方式為


Page.GetBackgroundParameters() Method

Version: Available or changed with runtime version 4.0.

Gets the page background task input parameters.

Syntax

Parameters :=   Page.GetBackgroundParameters()

Return Value

Parameters
 Type: Dictionary of [Text, Text]
The input parameters of the page background task.

Remarks

You use this method in a page background task codeunit, which is the codeunit that runs in a page background task. When a page background task is enqueued by the EnqueueBackgroundTask, it can include a set of parameters (a collection of key and value pairs) that can be used in the computations done in the background task codeunit. These parameters are passed as a dictionary of text to the codeunit's OnRun trigger when the page background task session is started. You use the GetBackgroundParameters method to retrieve these parameters.

Use the Evaluate method to convert parameter values to the data types required for calculations.

Example

The following code is an example of a page background task codeunit that uses the GetBackgroundParameters method to retrieve the value of the key named Wait, which is passed to the OnRun trigger from the calling page when the page background task is enqueued. 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