{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":3789,"path":"build-workflows/legacy-workflow/r_WorkflowEventsInTheBaseSystem.md","title":"Workflow events in the base system","bundle":null,"doc_type":null,"release":"australia","body":"\n# Workflow events in the base system\n\nSeveral workflow events are available in the base system.\n\n|Event|Description|Purpose|To use|Source|Thread|Listeners|\n|-----|-----------|-------|------|------|------|---------|\n|activityComplete|String value used by activity definitions to respond to the onActivityComplete event handler.|Informs records in the Workflow Executing Activity \\[wf\\_executing\\] table about the completion of other activities in the same workflow context.|If the activity is allowed to set the boolean value for `wf_executing.notify_termination`, then set the value to `true (activity.notify_termination = true)` during the onExecute event.|Workflow Engine, Process Terminations|Current thread, current mutex|**Join** activity|\n|otherEvent|String value used by the **Join** activity to respond to an otherEvent.|Informs records in the Workflow Executing Activity \\[wf\\_executing\\] table about an otherEvent that has completed.|The **Join** activity transitions from **n** number of preceding activities. These preceding activities all create a wf\\_executing record, which causes a check to see if the record already exists. If the **Join** already exists, then the **Join** created by the executing transition sets the wf\\_executing record for deletion.|**Join** activity|Current thread, current mutex|**Join** activity, onOtherEvent event handler|\n|timer|String value used by workflow activities to respond to a **Timer** activity that has expired.|Allows wf\\_executing records to be informed about a timer activity that has completed and has fired the timer event.|The **Timer** activity schedules a job that calls a script. The script calls fireEvent \\(wf\\_executing, timer\\).|**Timer** activity via a scheduled job|Worker thread, private mutex|**Timer** activity, onTimer event handler|\n|execute|String value used by workflow activities to respond to a **Timer** activity that has expired.|Informs a record in the wf\\_executing table with the initial state of **Executing** to proceed with its primary work.|The workflow engine, for each transition executed, creates an executing record with a state of **Executing**. Once created, the executing record is put in a queue for processing. For each item in the queue, the Rhino globals are established, the activity definition that drives the executing record is instantiated, and the run\\(\\) function is called. When the state of a record is **Executing**, this function always calls onExecute.|Workflow engine, via the WFActivity Handler|Current thread, current mutex|All activities, onExecute event handler|\n|execute \\(specific to **Lock**\\)|String value used by the **Lock** activity to respond to a waiting lock that is ready to make another attempt to obtain a specific lock. This execute is different than the previous execute because it is called on a separate thread, at specified intervals, and is treated as an outside event.|Informs a wf\\_executing record waiting to execute that the specified wait interval has passed and that it should attempt to get the lock again.|**Lock** activity schedules a job with a script that uses the workflow script include's fireEvent\\(wf\\_executing, 'execute'\\) method.|**Lock** activity via a scheduled job|Worker thread, private mutex|**Lock** activity, onExecute event handler|\n|determineApprovalState|String value used by approval activities to respond to a change in the overall approval status of the current record.|Informs wf\\_executing records for approval activities about an approval that completed and triggered the timer event.|**Approval Coordinator** both registers for the event and triggers the event. The child approvals have listeners that determine their approval state.|**Approval Coordinator** triggers the event during its onExecute|Current thread, current mutex|**Approval Coordinator**, **Approval - User**, and **Approval - Group** all have onDetermineApprovalState event handlers. If the state is anything but **Requested**, the activity is considered finished, and the approval state \\(**Approved**, **Rejected**, **Cancelled**\\) is set to the **wf\\_executing.result** column|\n|cancel \\(from within activity definitions\\)|String value used by workflow activities to respond to a request for cancellation.|Informs all wf\\_executing records in a context that the workflow is being canceled.|The **End** activity uses the global workflow.broadcastEvent\\('cancel'\\) to interrupt the currently running wf\\_executing records. This changes the state of those records to **Cancelled**.|**End** activity|Current thread, current mutex|All activities, onCancel event handler|\n|cancel \\(outside current context\\)|String value used by workflow activities to respond to a request for cancellation.|This event is the same as the cancel event above and handled the same. However, the management of this event is subtly different. This event informs all wf\\_executing records in a context that the workflow is being canceled. The event is managed via the onCancel event handler of each executing activity definition, but the event is called differently. In particular, the call to cancel from outside an activity definition is blocked by the current mutex. This is a significant difference in that the event does not interrupt a currently executing activity that is still operating within the parameters of the current mutex.|Any script can call cancel on a known executing context via the workflow script include. For example,`var w = new Workflow(); w.cancel(context); //`where `context` is a GlideRecord of the context to be canceled.|Any script include, scheduled job, UI action, or other source|Current thread, private mutex|All activities, onCancel event handler|\n|stop \\(see **End** activity\\)|The **End** activity checks for this event.|If the stop event is the current event, then the cancel operation of the **End** activity is bypassed.|Only in the **End** activity.|Any script can trigger or broadcast the stop event via a script include or workflow **Run Script** activity|Current thread, current mutex|This event is used by the **End** activity to exclude the **Cancel** activity and allow a workflow to end, even if canceled.|\n|listener|String value that the workflow \\(subflow\\) activity triggers as an event.|When a main workflow calls a subflow, the workflow keeps the ID of the subflow's context in the scratchpad. When the subflow is complete, it triggers the listener event via a business rule.|The listener event is passed to the parent context on completion of a subflow and is managed by the onListener action of the workflow activity.|Business rule that is triggered by the update of a workflow that has a parent|Current thread, current mutex|This event is used by a subflow to inform it's parent flow that it is complete. The parent workflow will react to this event and continue.|\n|probe\\_complete|String value triggered in the workflow by an Orchestration activity indicating that the MID Server has completed a task.|The probe\\_complete event is triggered from Orchestration sensor processors via the workflow helper function handleEventById.|The onProbe\\_complete event handler is in the WebServiceActivityHandler and is used by most Orchestration activities.|Event used to restate a workflow that is waiting for the MID Server to process a task or activity|Worker thread, private mutex|Orchestration activities|\n|pause|String value sent to a workflow from an SLA to pause the **Timer** activity.|When an SLA is paused, the SLA workflows must be paused if there is a timer running.|Use is exclusive to the SLA timer|SLA|Business rule thread, private mutex|**Timer** activity|\n|resume|String value used by the **Timer** activity to resume a paused timer \\(see pause\\).|When an SLA is resumed, the SLA workflows must be resumed as well.|Use is exclusive to the SLA timer.|SLA|Business rule thread, private mutex|**Timer** activity|\n\n-   **[Glide events relative to workflows](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/legacy-workflow/r_GlideEventsRelativeToWorkflows.md)**  \nWorkflow uses several Glide events.\n-   **[Workflow event-specific functions](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/legacy-workflow/r_WorkflowEventSpecificFunctions.md)**  \nThere are several functions that relate specifically to workflow events.\n-   **[Event-specific workflow activities](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/legacy-workflow/r_EventSpecificWorkflowActivities.md)**  \nThe following workflow activities trigger events.\n\n**Parent Topic:**[Workflow events](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/build-workflows/legacy-workflow/c_WorkflowEvents.md)\n\n"}}