---
sourceDocument: Australia ServiceNow AI Platform Capabilities
sourceDocumentLink: https://www.servicenow.com/docs/r/servicenow-platform

 Release :

    - australia

ft:locale :

    - en-US

ft:publication_title :

    - Australia ServiceNow AI Platform Capabilities

ft:clusterId :

    - platcap

bundleId :

    - platcap

workflow :

    - Platform


---

# Turnstile workflow activity

# Turnstile workflow
activity {#r_TurnstileActivity__zp4_pks_3x}

* Release version: Australia
* 
* Updated March 12, 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

The Turnstile activity limits how many times a workflow can pass through the same point.{#r_TurnstileActivity__wf-turnstile-activity-shortdesc}
Use this activity to prevent infinite loops. This activity is useful alongside the [Rollback To workflow activity](https://www.servicenow.com/docs/IfYPoOOKuPtwTk577MC3WA#r_RollbackTo "The Rollback To activity transitions directly to the activity specified by the outgoing transition line arrow.") activity.

## Results

You can assign a result value using the <var class="keyword varname">activity.result</var> variable from
within a script field of the activity. By default, the activity script evaluates if the
activity should continue to iterate or stop.
{#r_TurnstileActivity__table_fgs_n3w_yr__entry__2}

| Result | Description |
|-|-|
| Continue | The Allowed iterations value is greater than the number of times the workflow accessed this activity. |
| Cancel | The workflow accessed this activity more times than the Allowed iterations value. |
[Table 1. Turnstile activity results]

{#r_TurnstileActivity__table_fgs_n3w_yr}

## Input variables

Input variables determine the initial behavior of the activity.
{#r_TurnstileActivity__table_q4t_r3w_yr__entry__2}

| Field | Description |
|-|-|
| Allowed iterations | Number of times the workflow can pass through this activity before the turnstile ends the loop. |
[Table 2. Turnstile activity input variables]

{#r_TurnstileActivity__table_q4t_r3w_yr}

## Conditions

The conditions determine which transition comes after this activity.  
{#r_TurnstileActivity__table_yky_v3w_yr__entry__2}

| Field | Description |
|-|-|
| Continue | If the workflow has returned to this point an amount of times less than the allowed iteration. |
| Cancel | If the workflow has returned to this point an amount of times more than the allowed iteration. |
[Table 3. Turnstile activity conditions]

{#r_TurnstileActivity__table_yky_v3w_yr}

## States

The activity state tells the workflow engine what to do with the activity.
{#r_TurnstileActivity__table_amr_x3w_yr__entry__2}

| State | Description |
|-|-|
| Executing | The workflow engine knows to start the onExecute function of the activity. |
| Waiting | The workflow engine ignores the activity until a specific event to restart the activity is triggered. |
| Finished | The activity finished running. See the result value for the outcome of the activity. |
| Cancelled | This activity, or the workflow that contains this activity, was canceled. |
| Error | A JavaScript error occurred. Review the logs for error details. |
[Table 4. Turnstile activity states]

{#r_TurnstileActivity__table_amr_x3w_yr}

