{"title":"TaskScheduler.SetTaskReady(Guid [, DateTime]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/taskscheduler/taskscheduler-settaskready-method/","by":"JOP-AL","license":"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/methods-auto/taskscheduler/taskscheduler-settaskready-method, 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.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/taskscheduler/taskscheduler-settaskready-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Sets a task that runs a codeunit to the ready state.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"TaskScheduler.SetTaskReady(Guid [, DateTime]) Method","slug":"taskschedulersettaskreadyguid-datetime-method","at":0,"chars":1723},{"level":2,"title":"Syntax","slug":"syntax","at":223,"chars":93},{"level":2,"title":"Parameters","slug":"parameters","at":316,"chars":108},{"level":2,"title":"Return Value","slug":"return-value","at":424,"chars":67},{"level":2,"title":"Remarks","slug":"remarks","at":491,"chars":328},{"level":2,"title":"Example","slug":"example","at":819,"chars":709},{"level":2,"title":"Related information","slug":"related-information","at":1528,"chars":195}],"text":"# TaskScheduler.SetTaskReady(Guid [, DateTime]) Method\n> Version: _Available or changed with runtime version 1.0._\nSets a task that runs a codeunit to the ready state. The task will not run unless it is in the ready state.\n## Syntax\n```al\n[Ok := ]  TaskScheduler.SetTaskReady(Task: Guid [, NotBefore: DateTime])\n```\n## Parameters\nTask\nType: ../guid/guid-data-type\n*[Optional] NotBefore*\nType: ../datetime/datetime-data-type\n## Return Value\n*[Optional] Ok*\nType: ../boolean/boolean-data-type\n## Remarks\nScheduled tasks are shown in the Scheduled Tasks page in the client.\nIf no task exists with the task GUID provided to TaskScheduler.SetTaskReady, then the method will return false (no runtime error will occur).\nFor more information about the task scheduler, see Using the Task Scheduler<../../devenv-task-scheduler>.\n## Example\nThe following example creates a task, which isn't in IsReady state, then it does some more work, and finally it uses the SetTaskReady method to set the task to ready, but also to start at a later specified time (task ready time + 60 seconds + up to 3 seconds of random time).\n```al\nvar\n    TaskID: GUID;\nbegin\n    // Third parameter to TaskScheduler.CreateTask controls IsReady at task creation time\n    TaskID := TaskScheduler.CreateTask(CodeUnit::MyCodeUnit, CodeUnit::MyFailureCodeUnit, false);\n\n    // do something more work needed before starting the task\n\n    // set the task ready and to start after\n    TaskScheduler.SetTaskReady(TaskID, CurrentDateTime + 60*1000 + Random(3000));\nend;\n```\n## Related information\ntaskscheduler-data-type\nUsing the Task Scheduler<../../devenv-task-scheduler>\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}