{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":3873,"path":"build-workflows/workflow-activities/r_ApprovalUser.md","title":"Approval - User workflow activity","bundle":null,"doc_type":null,"release":"australia","body":"\n# Approval - User workflow activity\n\nThe **Approval - User** activity creates one or more individual user approvals.\n\n## Results\n\nThe result value is the final approval disposition. This disposition depends on the approval actions take by the approvers and the approval conditions specified in the **Wait for** or **When Anyone Rejects** fields. Possible result values are:\n\n-   Approved\n-   Rejected\n-   Deleted\n-   Cancelled\n\n## Input variables\n\n<table id=\"table_xql_rnw_w4\"><thead><tr><th>\n\nField\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td class=\"subhead\" colspan=\"2\">\n\nApproval - User When Specify when this activity generates a user approval record.\n\n</td></tr><tr><td>\n\nCondition\n\n</td><td>\n\nConditions which, if met, cause the individual approval to be generated. If the conditions are not met, the approval is skipped.\n\n</td></tr><tr><td class=\"subhead\" colspan=\"2\">\n\nApproval - User Approvers Specify the users whose approval will be requested.\n\n</td></tr><tr><td>\n\nUsers\n\n</td><td>\n\nThe users for the approval. Use the tree icon to select user reference fields from the current record to create approvals, such as `${assigned_to}`. If no user is selected, the activity automatically sets the approval to **Approved**. **Note:** Workflow only manages approval records generated by the Approval User activity. After starting the workflow, newly added approvals do not affect the workflow context.\n\n</td></tr><tr><td>\n\nGroups\n\n</td><td>\n\nGroups whose members should also receive approvals. Note that this is different than the **Approval - Group** activity, which creates a group approval in addition to the individual approvals. The tree icon can be used to select group reference fields from the current record to create approvals, such as `${assignment_group}`.\n\n</td></tr><tr><td class=\"subhead\" colspan=\"2\">\n\nApproval - User Condition Specify how the activity decides to approve or reject the approval, based on the responses from individual approvers.\n\n</td></tr><tr><td>\n\nWait for\n\n</td><td>\n\nA choice between different approval logics to determine which individual approvals result in approval of the activity's approval. Options are:-   **Anyone to approve:** Any user can approve and the first approval causes the activity to complete with a result of **approved**.\n-   **Everyone to approve:** All users must approve \\(see below for how a rejection is handled\\).\n-   **First response from anyone:** The first approval or rejection from any user causes the activity to complete.\n-   **Condition based on script:** Each time a user approves or rejects, the **Approval script** is called to determine if the activity should complete.\n\n</td></tr><tr><td>\n\nWhen anyone rejects\n\n</td><td>\n\nA choice between different approval logics to determine which individual rejections result in rejection of the activity's approval. Options are:\n\n-   **Reject the approval:** Immediately complete the activity with a result of **rejected**.\n-   **Wait for other responses before deciding:** Wait until we get other responses before making an approval or rejection decision. This allows users to change their mind until a decision is made.\n\n **Note:** Note that if **Wait for** is set to **Anyone to approve** then a single approval will cause the activity to complete with a result of **approved** even if one or more users reject.\n\n</td></tr><tr><td>\n\nApproval Column\n\n</td><td>\n\nA string field for the name of the approval field on the table the workflow is running on. The default value is **approval**, which is the field on the Task table.\n\n **Note:** Use the field's name, not its label.\n\nIf using any custom approval column fields and approval column journals, use Set Value activities in the workflow to set the custom Approval column fields.\n\n</td></tr><tr><td>\n\nApproval Journal Column\n\n</td><td>\n\n \n\n</td></tr><tr><td>\n\nApproval Script\n\n</td><td>\n\nIf the **Wait for** variable is set to **Condition based on script** this script is called to determine how to handle an approval or rejection. The script needs to set the variable *answer* to approved or rejected to indicate the approval status for this approval. When called, the following information is available:\n\n```\n counts.total = total number of users that are part of this approval\n                    counts.approved = # of users that approved so far\n                    counts.rejected = # of users that rejected so far\n                    counts.requested = # of users that are pending approval\n                    counts.not_requested = # of users that are not pending approval\n                    counts.not_required = # of users that approval is not required\n```\n\n</td></tr><tr><td class=\"subhead\" colspan=\"2\">\n\nApproval - User Schedule Specify how workflow calculates the approval record's expected start date and due date. Once you've made a selection for 'Due date based on', and 'Schedule based on', the appropriate fields will display.\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><tr><td class=\"subhead\" colspan=\"2\">\n\nApproval - Advanced If desired, write a script for determining additional users to request approvals from.\n\n</td></tr><tr><td>\n\nAdvanced\n\n</td><td>\n\nSelect this check box to write a script for determining additional users to request approvals from.\n\n</td></tr><tr><td>\n\nAdditional approvers script\n\n</td><td>\n\nIf the **Advanced** check box is selected, this script is called to determine any additional user approvals to be created. The script needs to set the variable *answer* to a comma-separated list of user ids and group ids or an array of user and group ids to add as approvers. For example:\n\n```\nanswer = [];\n       answer.push('id1');\n       answer.push('id2');\n```\n\n</td></tr></tbody>\n</table>## Conditions\n\nThe following conditions determine which transition runs after this activity.\n\n**Note:** Approval activities run as the user whose actions match the approve or reject conditions the workflow was waiting for and advances the workflow.\n\n|Condition|Description|\n|---------|-----------|\n|Approved|The users approved the request based on the **Wait for** rules.|\n|Rejected|The users rejected the request based on the **Wait for** rules.|\n|Error|The event or condition that generates an error.|\n|Skipped|The event or condition that allows a skipped approval.|\n\n## 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 starts the execute 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:**[Approval and rollback workflow activities](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/workflow-activities/c_ApprovalAndRollbackActivities.md)\n\n"}}