Wait for a duration flow logic

  • Release version: Xanadu
  • Updated August 1, 2024
  • 4 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Wait for a duration flow logic

    The "Wait for a duration" flow logic in ServiceNow enables automated workflows to pause for a specified time period or until a certain date and time. This functionality is useful for giving users time to take action during processes or for scheduling actions to complete at precise timings, improving automation accuracy and business process management.

    Show full answer Show less

    Inputs

    The flow logic supports three types of duration inputs to define how long the wait should be:

    • Explicit Duration: Wait for a fixed time period (e.g., 5 minutes).
    • Relative Duration: Wait for a period relative to a specific date/time or duration data pill (e.g., 5 minutes after flow start).
    • Percentage Duration: Wait for a percentage of the time between the start of the flow and a specified end time (value must be 0-100%).

    Users can enter durations manually or select duration values dynamically from data pills, such as SLA definitions, enabling flexible and data-driven wait times.

    Wait Configuration

    When specifying wait durations:

    • Explicit and Relative durations are entered in hours, minutes, and seconds, with a maximum wait of 999 hours.
    • Relative Duration calculates wait based on the relative date/time and considers schedules if specified.
    • Schedules can be applied to control wait timing according to business hours or custom calendars, ensuring waits respect operational schedules.
    • For Percentage Duration, the wait is proportional to the elapsed time between flow start and a designated end time, supporting timed notifications or escalations.

    Note that instance processing load may affect actual elapsed wait time.

    Outputs

    • Duration: Total flow runtime in milliseconds, useful for tracking elapsed time.
    • Date/time: Timestamp when the flow finishes waiting, enabling subsequent scheduling or actions.

    Practical Examples

    • Automatically close an incident 10 days after it reaches the Resolved state by waiting 10 days post-resolution before updating the record.
    • Send a notification email when 50% of the time between record creation and due date has elapsed, using Percentage Duration for time-based alerts.

    Relative Duration Behavior

    The flow logic handles past and future relative dates distinctly:

    • If the relative date/time is past or zero with no schedule, the wait ends immediately.
    • If the relative date/time is in the future, the flow waits until that time, and then waits for the specified duration.
    • If a schedule is set, waits respect business hours, pausing until the next schedule window if initiated outside those times.

    Execution Details

    Execution information includes flow state, start time, and runtime (excluding wait duration), along with detailed configuration and runtime values for variables, facilitating debugging and monitoring.

    Why it Matters for ServiceNow Customers

    This flow logic empowers customers to build robust, time-aware automation that respects operational calendars and user response windows. It enables automations such as SLA enforcement, timed notifications, and state transitions after delays, increasing process reliability and compliance.

    Use this flow logic to give your users time to act during automated processes or to wait for a specific date and time to complete actions.

    Inputs

    Input Description
    Duration Type
    • Explicit Duration: Wait for a specific time period, such as 5 minutes.
    • Relative Duration: Wait for a specific time period from a selected Duration data pill or date/time value, such as 5 minutes after the flow start.
    • Percentage Duration: Type to specify a certain percentage of time duration between the start of the flow logic and specified end time.
      Note:
      The percentage value must be from 0 through 100 only.
    Wait for Set this value manually or select a Duration data pill from the data pill picker (Data pill picker). For example, use a Look Up Record action to select an SLA Definition record and return the value of the Duration field.
    • Explicit Duration: Wait duration in hours, minutes, and seconds.
    • Relative Duration: Wait duration in hours, minutes, and seconds before or after a specific time. Select Relative Duration to specify a wait duration from a specific date.
      Note:
      Past dates don't affect the wait duration.
    You can enter a wait value of up to 999 hours.
    Note:
    The actual wait duration can vary due to the instance processing time. The flow always waits for the time that you specify for this field, but other work in the queue may add to the wait time.
    Wait for Percentage Wait duration as a percentage of the time period between the start of flow logic and specified end time. If you select a past date for the end time, the wait duration is set to 0. This field appears when Percentage Duration is selected from the Duration Type list.
    During the following schedule Select the schedule used to calculate the Scheduled End date/time value from the selected wait duration. For example, waiting for a 10-hour duration as part of an 8-5 weekdays schedule causes the flow to wait for one or more business days. If you leave this field blank, the timer runs without a schedule. For information on creating schedules, see Define a schedule.

    Outputs

    Output Description
    Duration Total time that the flow ran in milliseconds. You can drag this data pill into the duration fields.
    Date/time Date/time that the flow completed. You can drag this data pill into the date/time fields.

    Close an incident if it has been in the resolved state for 10 days

    In this example, a flow starts when the incident state changes to Resolved.

    Figure 1. Flow trigger
    Flow trigger.

    Wait 10 days after the last update to a record

    In this example, the flows waits for 10 days after the incident record has been resolved.

    Figure 2. Wait for Duration flow logic
    Wait for Duration flow logic.

    Update a record after 10 days

    In this example, the flows closes the incident record 10 days after it was resolved.

    Figure 3. Action used to close the incident
    Action used to close the incident.

    Wait for a duration of 50% of the time between the start of the flow logic and the due date

    In this example, the flows send a notification email to the relevant manager when a critical problem is created and 50% of the time between the problem record creation and the problem due date has lapsed.

    Figure 4. Wait for percentage time duration flow logic
    Wait for percentage time duration flow logic.

    Relative Duration type

    When the duration type is Relative Duration, the flow logic first evaluates the relative date and time, the schedule, and finally, the duration. Schedules, dates, and times set in the past don't affect the wait duration. This table provides examples of how the flow processes the wait duration in these scenarios.

    Duration Setting Relative Date/Time Schedule Effect
    Set to 0. None None Duration ends immediately.
    Greater than 0. Past date None Duration ends immediately.
    Greater than 0. Future date None Flow waits for the date/time, and then waits for the duration.
    Greater than 0. Past date Future date Flow waits for schedule, and then waits for the duration.
    Greater than 0. Future date Past date Flow waits for the date/time, and then waits for the duration.
    Greater than 0. Future date Future date Flow waits for the future date, then for the schedule, and then for the duration.

    The timer waits for the next instance of a selected schedule. For example, if you set a schedule for Monday through Friday from 8 a.m. to 5 p.m., and the timer is initiated on Saturday, the timer waits until Monday at 8 a.m. before starting.

    Execution details

    Figure 5. Execution details for Wait for a duration flow logic
    Example execution details for a wait for a duration flow.
    1. The header shows the state, start time, and runtime for the flow logic.
      Note:
      The runtime value in the header only includes the time that it takes to execute the flow logic and doesn't include the wait duration that is specified in the flow.
    2. The Configuration Details section shows details about the variables that are used by the flow, including the type, configuration, and runtime values for each variable.