Redaguoti

Bendrinti naudojant


TaskScheduler.TaskExists(Guid) Method

Version: Available or changed with runtime version 1.0.

Checks whether a specific task exists.

Syntax

Exists :=   TaskScheduler.TaskExists(Task: Guid)

Parameters

Task
 Type: Guid
The unique identifier of the task. The unique identifier is returned by the CreateTask method when creating the task.

Return Value

Exists
 Type: Boolean

Remarks

Scheduled tasks are shown in the Scheduled Tasks page in the client. The TaskScheduler.TaskExists method looks up if the task exists on the page (the implementation is different for the on-premises version compared to the online version of Business Central).

Note

It's also possible to use ScheduledTask.Get on a record instance of type ScheduledTask to query for existence of a task. This method requires the user to have Read access to the ScheduledTask table, whereas the TaskScheduler.TaskExists method doesn't require the user to have access to the ScheduledTask table.

For more information about the task scheduler, see Using the Task Scheduler.

Example

This example shows how to use TaskScheduler.TaskExists to be able to safely later in the code flow run code that assumes that the task exists.

procedure DoSomethingOnATask(ScheduledTaskId: Guid)
begin
    if not TaskScheduler.TaskExists(ScheduledTaskId) then 
    begin
        // handle error
    end;

    // code can now assume that tasks exists

    ...
end;

TaskScheduler Data Type
Using the Task Scheduler
Get Started with AL
Developing Extensions