Szerkesztés

Megosztás a következőn keresztül:


TaskScheduler.CreateTask(Integer, Integer, Boolean, Text, DateTime, RecordId, Duration) Method

Version: Available or changed with runtime version 7.0.

Adds a task to be run by the task scheduler. The task is ensured to not run before the specified time. This method also allows you to set a timeout for the task.

Syntax

[Task := ]  TaskScheduler.CreateTask(CodeunitId: Integer, FailureCodeunitId: Integer, IsReady: Boolean, Company: Text, NotBefore: DateTime, RecordID: RecordId, Timeout: Duration)

Parameters

CodeunitId
 Type: Integer
Specifies the ID of the codeunit to run.

FailureCodeunitId
 Type: Integer
Specifies the ID of the codeunit to run if the task fails. If you do not want to provide a failure codeunit, then use 0.

IsReady
 Type: Boolean
Sets the task to the ready state. A task cannot run unless it is ready.

Company
 Type: Text
Specifies the company to run the task for. If you do not specify a company, the task will run in the user’s current company.

NotBefore
 Type: DateTime
Specifies the date and time that you want to run the task. When the task actually runs will depend on whether other tasks are running at the same time. The task will run the first opportunity on or after the date and time that you specify.

RecordID
 Type: RecordId
Specifies the recordID of the record that you want to run the task on.

Timeout
 Type: Duration
Specifies the timeout of the created session. If not specified a default timeout will be used; for OnPrem, the default timeout is set on the server, for SaaS the current default timeout is 12 hours, and may change in the future.

Return Value

[Optional] Task
 Type: Guid

Remarks

This version of the TaskScheduler.CreateTask method has the same semantics as the version without a timeout parameter. For more information and usage examples, see CreateTask(Integer, Integer [, Boolean] [, Text] [, DateTime] [, RecordId]).

CreateTask(Integer, Integer [, Boolean] [, Text] [, DateTime] [, RecordId])
TaskScheduler Data Type
Using the Task Scheduler
Get Started with AL
Developing Extensions
Configuring Business Central Server - Default Task Scheduler Session Timeout