Scheduling a Workflow

When you set up a workflow to run on a schedule, it runs on the results of a saved search. When you schedule a workflow, select a saved search and set the schedule when it runs. You can schedule the workflow to run one time, every 30 minutes, or at a certain time on a daily, weekly, monthly, or yearly basis.

Before you define the schedule for the workflow, you must create the saved search. The saved search must run on the same record type as the base record type for the workflow. The saved search must also include at least one filter set on the Criteria subtab. On the workflow definition page, select the Scheduled, select the saved search, and set the schedule.

Important:

When you create a saved search, make sure you add enough filters on the Criteria subtab to limit results to only the records you want the workflow to run on. If you don't include enough filter criteria, the saved search may return too many results, and the scheduled workflows won't execute as expected. For example, the workflow could run longer than you expect, and may affect the performance of other workflows.

At the scheduled time, NetSuite runs the saved search and initiates a workflow instance for each record in the search results. For example, if the saved search returns 10 records, NetSuite initiates 10 workflow instances. Scheduled workflows always run on all of the records in the search results, not only the records you see on the main page (for summary type result) of the saved search.

To set up a scheduled workflow, select the saved search it should run on and select the schedule options. You can schedule the saved search and workflow to run one time, or use the Repeat option for a repeating schedule. If you want the workflow to run one time, select the saved search, clear the Repeat box, and set the Execution Date and Execution Time. If you want the workflow to run more than one time, select the saved search, check the Repeat box, and set the related options.

Consider the following when you create scheduled workflows:

For more information about how NetSuite runs scheduled workflows, see Initiating a Workflow on a Schedule and Scheduled Trigger.

To create a scheduled workflow:

  1. Create a saved search on the base record type you want the workflow for.

    Warning:

    The saved search must include at least one filter on the Criteria subtab. Make sure you add enough filters so only the records you want are used in the workflow.

    For more information, see Defining a Saved Search.

  2. Go to Customization > Workflow > Workflows > New. The workflow definition page appears.

  3. Under Basic Properties, set the following basic properties:

    Property

    Description

    Name

    Name for the workflow. Can be up to 40 characters.

    Workflows on the Workflow list page appear with this name. This name is also used on the record for workflow instances on the Active Workflows and Workflow History subtabs.

    ID

    Optional script ID for the workflow. It must be lowercase, can't include spaces, and can't be more than 26 characters.

    Use script IDs if you plan to bundle and deploy the workflow and to another NetSuite account. Script IDs help prevent naming conflicts in other accounts.

    NetSuite prefixes this value with customworkflow when you save the workflow.

    You can change the script ID after you create the workflow. See Editing a Workflow Script ID.

    Record Type

    The record type where you want workflow instances to run. This record type can be a standard or custom NetSuite record type.

    You can specify only one base record type per workflow. If you select Customer, Transaction, or Item, you can also select a sub type.

    See Workflow Base Record.

    Sub Type

    Sub type or secondary record type for customer, transaction, or item record types. Hold down the Ctrl key to select more than one.

    Description

    Optional text description.

    Owner

    The user account that owns the workflow and receives email messages if errors occur during scheduled workflow actions.

    With a Release Status of Testing, only the workflow owner can start it. See Release Status.

    Execute As Admin

    Means the workflow runs as a user with an Administrator role and ignores the user role.

    Using this property may give users more access than you want. For more information about this property and usage guidelines, see Execute As Admin.

    Release Status

    Release status of the workflow. Set the status to Released to run on a schedule. With Testing, you can run a scheduled workflow immediately with the Execute Now button. See Testing Scheduled Workflows.

    Keep Instance and History

    Indicates whether workflow history is saved as the workflow run and after it finishes. Workflow history records are available in execution and error log records. You can select one of the following options:

    • Only When Testing. When you select this option, workflow history records are kept only when the Release Status of the workflow is set to Testing.

    • Never. When you select this option, workflow history records are never kept.

    • Always. When you select this option, workflow history records are always kept.

    By default, the Only When Testing is selected when you create new workflows.

    If you select Never, instance and history records are available on the Active Workflows and Workflow History subtabs for the record while the workflow is running. When the workflow is done or canceled, related the history records. History records are never deleted for workflows that transition to a state with the Do Not Exit Workflow box checked.

    Note:

    This setting only impacts newly created history records. If you change the Keep Instance and History setting, existing workflows will not be impacted.

    Enable Logging

    Means that NetSuite generates a workflow execution log for each state entered during workflow execution.

    In testing mode, this box is checked by default, but in released mode, you need to check the box yourself.

    For more information about the workflow execution log, see Workflow Execution Log.

    Inactive

    Means that no new workflow instances initiate for the workflow and don't appear by default on the Workflow list page.

  4. Under Initiation, select Scheduled, and then in the Saved Search list, select the saved search you created in Step 1.

    Note:

    To create an event-based workflow, see Creating a Workflow.

  5. If you want the schedule to repeat, check the Repeat box.

  6. Enter the following schedule options:

    Option

    Description

    Frequency

    How often you want the scheduled workflow to run. You can select one of the following options:

    • Every 30 minutes

    • Daily

    • Weekly

    • Monthly

    • Yearly

    If you select a daily, weekly, monthly, or yearly schedule, you need to set more options to define the schedule.

    The default is every 30 minutes.

    Scheduled From Date

    Date when the schedule starts. The first run depends on the schedule type and options.

    Scheduled Until Date

    Date when the schedule ends. The last run depends on the schedule type and options.

    Execution Time

    Time of day when NetSuite runs the saved search and runs the workflow on the results. The default is midnight.

  7. If you select a daily, weekly, monthly, or yearly schedule, set one of the following related options:

    Schedule Type

    Options

    Daily

    Set the interval for the number of days between runs or make it repeat every weekday.

    Weekly

    Set the interval for the number of weeks between runs and which days of the week it should run.

    Monthly

    Set a specific day of the month (for example, 8th day) or the day of the week (for example, second Tuesday). For both, you can also set the time period (for example, every 2 months). You can set the occurrence of the day using:

    • first

    • second

    • third

    • fourth

    • last

    Yearly

    Set the specific day in a specific month (for example, 8th of September) or the day of the week (for example, second Tuesday in September). You can set the occurrence of the day using:

    • first

    • second

    • third

    • fourth

    • last

  8. Click Save. NetSuite creates the workflow and opens it in the Workflow Manager.

    You can continue to define the workflow by adding states. See Working with States.

Related Topics

General Notices