---
sourceDocument: Xanadu Build or modify applications
sourceDocumentLink: https://www.servicenow.com/docs/r/xanadu/application-development

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu Build or modify applications

ft:clusterId :

    - cadev

bundleId :

    - cadev

workflow :

    - Development, Data, and Analytics


---

# Business Rule API - ServiceNow Fluent

# Business Rule API - ServiceNow Fluent {#ariaid-title1}

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

The Business Rule API defines server-sides scripts \[sys_script\] that run when a record is displayed, inserted, updated, or deleted, or when a table is queried.
For general information about business rules, see [Classic Business rules](https://www.servicenow.com/docs/access?context=c_BusinessRules&version=xanadu&pubname=xanadu-api-reference&ft:locale=en-US).
**Related concepts**   

* [ServiceNow Fluent](https://www.servicenow.com/docs/e_U08PErXJdneo77q8TISQ "Define application metadata in source code using the ServiceNow Fluent domain-specific programming language.")

## BusinessRule object {#ariaid-title2}

Create a business rule \[sys_script\] that automatically changes values in form fields when certain server-side conditions are met.
{#business-rule-object-now-ts__table_vy2_525_jq__entry__3}{#business-rule-object-now-ts__now-id-desc2}

| Name | Type | Description |
|-|-|-|
| $id | String or Number | Required. A unique ID for the metadata object. When you build the application, this ID is hashed into a unique sys_id. For more information, see [ServiceNow Fluent language constructs](https://www.servicenow.com/docs/clNBhv~lgnZYg~KLL84Hjw "ServiceNow Fluent language constructs provide additional functionality for development in source code with ServiceNow Fluent APIs."). Format: `Now.ID['String' or Number]` |
| name | String | Required. A name for the business rule. |
| table | String | Required. The name of the table on which the business rule runs. |
| script | Script | A custom script runs when the defined conditions are true. This property supports a function from a JavaScript module, a reference to another file in the application that contains a script, or inline JavaScript. Format: * For functions, use the name of a function, function expression, or default function exported from a JavaScript module and import it into the .now.ts file. For information about JavaScript modules, see [JavaScript modules and third-party libraries](https://www.servicenow.com/docs/~hgNIdknFEpmBqpxVylH0A "Optimize your code base using JavaScript modules to group related code or add third-party libraries and reuse their code within applications.").{#business-rule-object-now-ts__script-function} * To use text content from another file, refer to a file in the application using the following format: `Now.include('path/to/file')`. For more information, see [ServiceNow Fluent language constructs](https://www.servicenow.com/docs/clNBhv~lgnZYg~KLL84Hjw "ServiceNow Fluent language constructs provide additional functionality for development in source code with ServiceNow Fluent APIs."). * To provide an inline script, use string literals or template literals for multiple lines of code: ``'Script' or `Script```. {#business-rule-object-now-ts__ul_rtr_vyd_1gc} |
| order | Number | A number indicating the sequence in which the business rule should run. If there are multiple rules on a particular activity, the rules run in the order specified, from lowest to highest. Default: 100 |
| active | Boolean | Flag that indicates whether the business rule is enabled. Valid values: * true: The business rule is enforced. * false: The business rule isn't enforced. {#business-rule-object-now-ts__ul_cxj_srr_4bc} Default: true |
| when | String | The time that the business rule should execute. For more information about when business rules run, see [How business rules work](https://www.servicenow.com/docs/access?context=c_BusinessRules&version=xanadu&pubname=xanadu-api-reference&section=r_HowBusinessRulesWork&ft:locale=en-US). Valid values: * before * after * async * display {#business-rule-object-now-ts__ul_onp_rpn_rfc} Default: before |
| action | Array | The record options that the business rule applies to. For more information about business rule actions, see [How business rules work](https://www.servicenow.com/docs/access?context=c_BusinessRules&version=xanadu&pubname=xanadu-api-reference&section=r_HowBusinessRulesWork&ft:locale=en-US). Valid values: * insert * update * delete * query {#business-rule-object-now-ts__ul_p5z_cqn_rfc} |
| addMessage | Boolean | Flag that indicates whether to add a message that appears when the business rule runs. Valid values: * true: Displays a message. * false: Doesn't display a message. {#business-rule-object-now-ts__ul_xxs_ws5_pbc} Default: false |
| abortAction | Boolean | Flag that indicates whether to abort the current database transaction. For example, on a before insert business rule, if the conditions are met, don't insert the record into the database. Valid values: * false: Doesn't abort the current database transaction. * true: Aborts the current database transaction. You can't perform additional actions on the record, such as setting field values and running scripts. You can still display a message to users with the addMessage and message properties. {#business-rule-object-now-ts__ul_l12_ht5_pbc} Default: false |
| message | String | A message that appears when the business rule runs. |
| roleConditions | Array | A list of variable identifiers of Role objects that users who are modifying records in the table must have for the business rule to run. For more information, see [Role API - ServiceNow Fluent](https://www.servicenow.com/docs/cPwq5eRiroGd0Ym9Uyg~jg#role-api-now-ts "The Role API defines roles [sys_user_role] that grant specific permissions to users of an application."). |
| condition | String | A JavaScript conditional statement that specifies the fields and values that must be true for the script to run. This property supports inline JavaScript or a reference to another file in the application that contains a script. Note: Don't use this property if you include the condition statement with the filterCondition or script properties. By specifying the condition statement with this property, the condition is evaluated separately, and the business rule runs only if the condition is true. To have the condition statement reevaluated a second time before running an async business rule, set the glide.businessrule.async_condition_check system property to true. Format: * To use text content from another file, refer to a file in the application using the following format: `Now.include('path/to/file')`. For more information, see [ServiceNow Fluent language constructs](https://www.servicenow.com/docs/clNBhv~lgnZYg~KLL84Hjw "ServiceNow Fluent language constructs provide additional functionality for development in source code with ServiceNow Fluent APIs."). * To provide an inline script, use string literals or template literals for multiple lines of code: ``'Script' or `Script```. {#business-rule-object-now-ts__ul_zr2_zvg_5fc} |
| filterCondition | String | A filter query that specifies the fields and values that must be true for the business rule to run. For more information, see [Operators available for filters and queries](https://www.servicenow.com/docs/access?context=r_OpAvailableFiltersQueries&version=xanadu&pubname=xanadu-platform-user-interface&ft:locale=en-US). |
| setFieldValue | String | The values to set for fields in the table. This can be provided as an encoded query, such as `setFieldValue: 'sec_created=false^EQ'`. |
| description | String | A description of what the business rule does. |
| protectionPolicy | String | A policy that determines whether someone can view or edit the script include after the application is installed on their instance. If undefined, other application developers can customize the script include. Valid values: * read: Allows anyone to read values from this downloaded or installed script include. No one can change script values on the instance on which they download or install the script include. * protected: Provides intellectual property protection for application developers. Customers who download the script include cannot see the contents of the script field. The script is encrypted in memory to prevent unauthorized users from seeing it in plain text. {#business-rule-object-now-ts__ul_o3h_nbz_j3c} |
| $meta | Object | Metadata for the application metadata. With the installMethod property, you can map the application metadata to an output directory that loads only in specific circumstances. $meta: { installMethod: 'String' } Valid values for installMethod: * demo: Outputs the application metadata to the metadata/unload.demo directory to be installed with the application when the Load demo data option is selected. * first install: Outputs the application metadata to the metadata/unload directory to be installed only the first time an application is installed on an instance. {#business-rule-object-now-ts__ul_n3q_y3s_42c} |
[Table 1. Properties]

{#business-rule-object-now-ts__table_vy2_525_jq}  

    import { BusinessRule } from '@servicenow/sdk/core'
    import { FunctionExport, FunctionExpression } from '../server/scripts.js'
    import DefaultExportFunction from '../server/scripts.js'

    const BR1 = BusinessRule({
        name: 'exportedFunction',
        table: 'x_snc_table',
        when: 'after',
        action: ['update', 'delete', 'insert'],
        script: FunctionExport,
        order: 100,
        active: true,
        addMessage: false,
        message: '<p>message</p>',
        abortAction: false,
        $id: Now.ID[0],
    })

    const BR2 = BusinessRule({
        name: 'businessrule2',
        table: 'x_snc_table',
        script: FunctionExpression,
        when: 'after',
        action: ['update'],
        $id: Now.ID[1],
    })

    const BR3 = BusinessRule({
        name: 'businessrule3',
        table: 'x_snc_table',
        script: DefaultExportFunction,
        when: 'after',
        action: ['update'],
        filterCondition: `sys_updated_onSTARTSWITHb^sys_updated_bySTARTSWITHm^EQ
        <item goto="false" or="false" field="sys_updated_on" endquery="false" value="b" operator="STARTSWITH" newquery="false"/>
        <item goto="false" or="false" field="sys_updated_by" endquery="false" value="m" operator="STARTSWITH" newquery="false"/>
        <item goto="false" or="false" field="" endquery="true" value="" operator="=" newquery="false"/>`,
        $id: Now.ID[2],
    })

    const BR4 = BusinessRule({
        name: 'templateBR',
        action: ['insert'],
        when: 'after',
        table: 'x_snc_table',
        roleConditions: [admin],
        order: 100,
        active: true,
        addMessage: true,
        message: '<p>message</p>',
        script: `gs.info('info')`,
        abortAction: false,
        $id: Now.ID[3],
    })


