{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":3879,"path":"build-workflows/workflow-activities/r_CreateTask.md","title":"Create Task workflow activity","bundle":null,"doc_type":null,"release":"australia","body":"\n# Create Task workflow activity\n\nThe **Create Task** activity generates a record on any of the tables that extend Task \\[task\\].\n\n**Note:** This activity is only available when the workflow runs on a table that extends Task.\n\nIf the **Wait for completion** check box is selected, the workflow context waits for a user action on the task, such as Complete or Incomplete, and then progresses based on the user action.\n\n**Note:** Task activities run as the user whose actions complete the task the workflow was waiting for and advances the workflow.\n\n## Results\n\nYou can assign a result value using `activity.result` from within a script field of the activity. By default, the final **State** value of the task record determines the result value for the **Create Task** activity. Possible result values are:\n\n-   Closed complete\n-   Closed incomplete\n-   Closed skipped\n-   Deleted\n-   Cancelled\n\n## Input variables\n\nThe following variables determine the behavior of the activity.\n\n<table id=\"table_jlf_nrc_sp\"><thead><tr><th>\n\nField\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td class=\"subhead\" colspan=\"2\">\n\nCreate Task Activity SettingsThe following fields specify the behavior of the Create Task Activity.\n\n</td></tr><tr><td>\n\nTask type\n\n</td><td>\n\nThe type of task to create. Select from the corresponding task table for the workflow.\n\n</td></tr><tr><td>\n\nPriority\n\n</td><td>\n\nThe default priority assigned to the task. If you also set the Task priority in the **Task values from** section, the Task value overrides the default priority.\n\n</td></tr><tr><td>\n\nWait for completion\n\n</td><td>\n\nIf selected, the workflow activity waits for the task to complete before continuing. If cleared, the task is created but the workflow proceeds.\n\n</td></tr><tr><td class=\"subhead\" colspan=\"2\">\n\nCreate Task Record Settings The following fields specify the field values that this activity sets for the task it creates.\n\n</td></tr><tr><td>\n\nTask values from\n\n</td><td>\n\nThe values used to create the task may either come from:-   **Fields:** a predefined set of fields including **Fulfillment group**, **Assigned to**, **Short description** and **Instructions**.\n-   **Template:** an existing template for the selected task table.\n-   **Values:** values that you specify using a Set Values widget.\n\n **Note:** Any Task priority you set here overrides the default priority set by the **Priority** field.\n\n</td></tr><tr><td>\n\nFulfillment groupOnly appears when **Task value from** is set to `Fields`\n\n</td><td>\n\nThe group that is responsible for completing the task. Populates the **Assignment group** field on the new task.\n\n</td></tr><tr><td>\n\nAssigned toOnly appears when **Task value from** is set to `Fields`\n\n</td><td>\n\nThe user who is responsible for completing the task. Populates the **Assignment to** field on the new task.\n\n</td></tr><tr><td>\n\nShort descriptionOnly appears when **Task value from** is set to `Fields`\n\n</td><td>\n\nA short description for the task. Populates the **Short description** field on the new task.\n\n</td></tr><tr><td>\n\nInstructionsOnly appears when **Task value from** is set to `Fields`\n\n</td><td>\n\nThe task instructions for the user to complete prior to closing the task. Populates the **Description** field on the new task.\n\n</td></tr><tr><td>\n\nTask templateOnly appears when **Task values from** is set to **Template**.\n\n</td><td>\n\nA template that is used to fill in values for the task.\n\n</td></tr><tr><td>\n\nSet valuesOnly appears when **Task values from** is set to **Values**.\n\n</td><td>\n\nA widget that is used to specify values for any fields of the task.\n\n</td></tr><tr><td class=\"subhead\" colspan=\"2\">\n\nAdvanced\n\n</td></tr><tr><td>\n\nAdvanced\n\n</td><td>\n\nCheck **Advanced** if you want to use a script to assign values on the catalog task. When you check **Advanced,** a text box appears where you can enter your script.\n\n</td></tr><tr><td>\n\nAdvanced Script Only appears when the **Advanced** field is checked.\n\n</td><td>\n\nSet additional values for the task in this script. This script is run after the task values are set using the **Fields**, **Template** or **Values** you have specified. Use the variable *task* when setting additional values, for example:\n\n `task.short_description = current.short_description;`\n\n</td></tr><tr><td class=\"subhead\" colspan=\"2\">\n\nTask Schedule\n\n</td></tr><tr><td>\n\nDue date based on\n\n</td><td>\n\nSelect how workflow determines the task's duration, due date, and schedule. -   **A user specified duration:** The duration is based on a user specified value.\n-   **A relative duration:** The duration is calculated from a relative duration \\(such as End of Next Business Day\\).\n-   **A date/time or duration field:** The duration is based on the value of a field on the current record.\n-   **Script:** The duration is returned by a script.\n\n</td></tr><tr><td>\n\nDuration Only appears when **Due date based on** is set to `A user specified duration`\n\n</td><td>\n\nThe specific number of days and hours.\n\n</td></tr><tr><td>\n\nRelative durationOnly appears when **Due date based on** is set to `A relative duration`\n\n</td><td>\n\nThe general number and length of business days.\n\n</td></tr><tr><td>\n\nDue date fieldOnly appears when **Due date based on** is set to `A date/time or duration field`\n\n</td><td>\n\nThe date/time or duration field.\n\n</td></tr><tr><td>\n\nDue date scriptOnly appears when **Due date based on** is set to `Script`\n\n</td><td>\n\nThe script that sets 'answer' to the number of seconds for the duration.\n\n</td></tr><tr><td>\n\nSchedule based on\n\n</td><td>\n\nThe basic schedule the timer uses to count working hours. If a schedule is specified, the duration will only be considered for times that are specified on the schedule. For example, if the duration is 2 hours and the workflow begins at 4:00pm on a schedule that is 8am - 5pm, then it ends at 9:00am the next day. The options are: -   **This workflow's schedule:** The schedule uses workflow context date, time, and an optional **Time zone based on** value.\n-   **A specific schedule:** The schedule uses a pre-defined **Schedule** and an optional **Time zone based on** value.\n-   **A schedule field:** The schedule uses a value from a table and an optional **Time zone based on** value.\n\n</td></tr><tr><td>\n\nScheduleOnly appears when **Schedule based on** is set to `A specific schedule`\n\n</td><td>\n\nThe predefined **Schedule** from a list.\n\n</td></tr><tr><td>\n\nSchedule fieldOnly appears when **Schedule based on** is set to `A schedule field`.\n\n</td><td>\n\nA date and time or duration field for the schedule, that is associated with the table. Valid fields appear in blue on the Select the element from a tree dialog.\n\n</td></tr><tr><td>\n\nTime zone based on\n\n</td><td>\n\nThe time zone for calculating the duration. The time zone may be based on:-   **No time zone:** Default. Workflow uses the GMT time zone.\n-   **A specific time zone:** A specific **Time zone** that you choose from a choice list.\n-   **A time zone field:** A **Time zone field** to track time duration from a field on the form.\n\n</td></tr><tr><td>\n\nTime zoneOnly appears when **Time zone based on** is set to `A specific time zone`\n\n.\n\n</td><td>\n\nSelect the time zone you want from the choice list.\n\n</td></tr><tr><td>\n\nTime zone fieldOnly appears when **Time zone based on** is set to `A time zone field.`\n\n</td><td>\n\nA date and time or duration field for the schedule, that is associated with the table. Valid fields appear in blue on the Select the element from a tree dialog.\n\n</td></tr></tbody>\n</table>## States\n\nThe activity state tells the workflow engine what to do with the activity.\n\n|State|Description|\n|-----|-----------|\n|Executing|The workflow engine knows to start the onExecute function of the activity.|\n|Waiting|The workflow engine ignores the activity until a specific event to restart the activity is fired.|\n|Finished|The activity finished running. See the result value for the outcome of the activity.|\n|Cancelled|This activity, or the workflow that contains this activity, was canceled.|\n|Error|A JavaScript error occurred. Review the logs for error details.|\n\n**Parent Topic:**[Task workflow activities](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-activities/r_TaskActivities.md)\n\n"}}