--- title: Classic Business rules description: A business rule is a server-side script that runs when a record is displayed, inserted, updated, or deleted, or when a table is queried.To configure business rules, you first need to determine when the business rule should run and what action it should take.Every business rule is assigned to either a private application scope or to the global scope.You can create any type of business rule to run when a record is displayed, inserted, updated, or deleted, or when a table is queried.Predefined global variables are available for use in business rules.Implement both business rules and client scripts for a field to enable users to set record values properly using both forms and lists, and to see immediate changes to the values in forms as edits are made.The string NULL has a particular role in scripts and is a reserved word.Display rules are processed when a user requests a record form.This business rule determines whether the active field value needs to change based on changes to the State field.Find an example business rule script that helps you with a requirement of your organization.It is possible to compare two date fields or two date and time fields in a business rule, and abort a record insert or update if they are not correct.Fields in XML format can be parsed with the system's getXMLText function.In a before business rule script, you can cancel or abort the current database action using the setAbortAction\(\) method.You can write a script for a business rule that is triggered on more than one database action.An OR condition can be added to any query part within a business rule.A field defined as a glide list is an array of values stored in a single field.Use indexOf\("searchString"\) to return the location of the string passed into the method if the glide list field, such as a Watch list, has at least one value in it.You can lock user accounts if the user is not active.You can use a query business rule that executes before a database query is made. locale: en-US canonical_url: https://www.servicenow.com/docs/r/build-workflows/business-rules-classic/c\_BusinessRules.html release: australia product: Business rules \(Classic\) classification: business-rules-classic topic_type: concept last_updated: "2026-03-12" reading_time_minutes: 28 breadcrumb: [Build workflows] --- # Classic Business rules A business rule is a server-side script that runs when a record is displayed, inserted, updated, or deleted, or when a table is queried. Business rules are scripts that run when certain server-side conditions are met. Business rule conditions include when to run a business rule in relation to a database operation, and what record operations the business rule applies to. There are other scripting options available on the platform for client-side conditions, such as client scripts and UI actions. **Note:** Business rules are a classic automation solution that rely on scripting. Use Workflow Studio for any new process automation to create automations that are easier to extend, reuse, understand, and upgrade. As many organizations have business rules in production, use this documentation to learn how to work with existing business rules. ## How business rules work To configure business rules, you first need to determine when the business rule should run and what action it should take. ### When business rules run Business rules run based on two sets of criteria. - When to run the business rule in relation to a database operation. - What record operation the business rule applies to. The following options are provided to determine when the business rule should run.
| Option | When the rule runs |
|---|---|
| Before | After the user submits the form but before any action is taken on the record in the database. |
| After | After the user submits the form and after any action is taken on the record in the database. |
| Async | After the user submits the form and after the scheduler runs the scheduled job created from the business rule. The system creates a scheduled job from the business rule after the user submits the form but before any action is taken on the record in the database. **Note:** Newly created business rules will run during upgrades. If a record has an asynchronous business rule that makes decisions based on the data in the record, multiple updates to the record in quick succession can cause the business rule to execute out of order or incorrectly. If multiple async business rules update the same record, the updates performed by one script could be overwritten by another script or made in an unexpected sequence because the order of execution isn't guaranteed. You can use the After option for business rules or [System Events](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/build-workflows/system-events/events.md) as an alternative in these situations. |
| Display | Before the form is presented to the user, just after the data is read from the database. |
| Field | Description |
|---|---|
| Name | Enter a name for the business rule. |
| Table | Select the table that the business rule runs on.**Note:** The list shows only tables and database views that meet the scope protections for business rules. Business rules defined for a database view can run only on **Query**. A business rule for a database view cannot run on insert, update, or delete. |
| Application | Application that contains this business rule. |
| Accessible from | Scope protection for a global business rule. **Note:** This field is visible only when the **Table** field is set to **Global**. It does not apply to rules that run on specific tables. |
| Active | Select this check box to enable the business rule. |
| Advanced | Select this check box to see the advanced version of the form. |
| When to run | |
| When | \[Advanced\] Select when this business rule should execute: **display**, **before**, **async**, or **after** the database operation is complete. **Note:** Consider setting the **Order** for **async** business rules as the system uses this value when creating the associated scheduled job. Newly created **async** business rules run automatically on upgrade. Existing **async** business rules can be migrated to use the new async behavior. |
| Order | \[Advanced\] Enter a number indicating the sequence in which this business rule should run. If there are multiple rules on a particular activity, the rules run in the order specified here, from lowest to highest. |
| Insert | Select this check box to execute the business rule when a record is inserted into the database. |
| Update | Select this check box to execute the business rule when a record is update. |
| Delete | \[Advanced\] Select this check box to execute the business rule when a record is deleted from the database. |
| Query | \[Advanced\] Select this check box to execute the business rule when a table is queried. |
| Filter Conditions | Use the condition builder to determine when the business rule should run based on the field values in the selected Table.If you select the **Advanced** option, you can also use the **Condition** field to build a condition with a script. Conditions defined with the **Filter Conditions** field and advanced **Conditions** field are evaluated at the same time. **Note:** Filters based on string compares are case-sensitive. |
| Role Conditions | Select the roles that users who are modifying records in the table must have for this business rule to run. |
| Actions | |
| Set field values | Set values for fields in the selected Table using the choice lists:- The field - The assignment operator: - **To:** An exact value - **Same as:** The value of another field - **To \(dynamic\):** A value relative to the user configuring the business rule or a user with a specific role - The value |
| Add message | Select this check box and enter a message that appears when this business rule is run |
| Abort action | Select this check box to abort the current database transaction. For example, on a before insert business rule, if the conditions are met, do not insert the record into the database. If you select this option, you cannot perform additional actions on the record, such as setting field values and running scripts. You can still display a message to users by selecting the **Add message** check box and composing the message. |
| Advanced | |
| Condition | Create a JavaScript conditional statement to specify when the business rule should run. By adding the condition statement to this field, you tell the system to evaluate the condition separately and run the business rule only if the condition is true. If you decide to include the condition statement in the **Script** field or the **Filter Conditions** field, leave this field blank. Conditions defined with the **Filter Conditions** field and advanced **Conditions** field are evaluated at the same time. To have the instance reevaluate the condition statement a second time before running an async business rule, add the system property **glide.businessrule.async\_condition\_check** and set the value to true. |
| Script | \[Advanced\] Create a script that runs when the defined condition is true. - onAfter - onAsync - onBefore - onDisplay For more information and examples, see [Example business rule scripts](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/build-workflows/business-rules-classic/c_BusinessRules.md). |
| Related list: Versions | |
| Versions | Shows all versions of the business rule. Use this list to compare versions or to revert to a previous version. |