---
sourceDocument: Brazil API Reference
sourceDocumentLink: https://www.servicenow.com/docs/r/api-reference

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Debug business rules

# Debugging business rules {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) 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 Debugging business rules

This guide explains how ServiceNow customers can effectively debug business rules using built-in platform tools and scripting techniques.
It focuses on identifying issues, verifying variable values, and locating the correct data for business rules to function as intended.
Show full answer Show less  

## Tools

Several ServiceNow tools support debugging business rules:

* **System Dictionary:** Access via System Definition \> Dictionary to locate tables and understand their structure.
* **System Log:** Use System Logs \> System Log to view alert statements written by business rule scripts.
* **Debug Business Rule (Details):** Found under System Diagnostics \> Session Debug, this module shows if business rule conditions are met and values set as expected.
* **Alert Messages:** System functions allow printing messages to the page, fields, or log files for immediate feedback.
* **Business Rule Examples:** Reviewing existing scripts can provide insights, including handling error messages and complex queries.
* **GlideRecord Information:** Use GlideRecord syntax to query tables and aggregate data, essential for verifying data retrieval in scripts.

## Variables

To understand business rule behavior, verify that your queries return expected records. For example, use `gs.addInfoMessage` to display results directly on the UI, confirming whether the query returns true or false.

Example technique:

    var rec = new GlideRecord('incident');rec.addQuery('active', true);rec.query();gs.addInfoMessage("This is rec.next: " + rec.next());while (rec.next()) { gs.print(rec.number + ' exists');}

Break down scripts into smaller parts to individually test each piece before reintegrating to isolate issues effectively.

## Locating information

Understanding table extensions is crucial for querying the correct data. For example, `sctask` extends `task`. When needed, query both the extended and parent tables by sysid to access related fields, such as work notes.

Example approach:

    var kids = new GlideRecord('sctask');kids.query();while (kids.next()) { var parents = new GlideRecord('task'); parents.addQuery('sysid', '=', kids.sysid); parents.query(); while (parents.next()) { gs.addInfoMessage("Task number: " + parents.number); gs.addInfoMessage("Work notes: " + parents.worknotes); }}

This ensures you retrieve comprehensive information even when data spans extended tables.  
Debugging business rules can be achieved with resources available in the ServiceNow product.

## 1. Tools

The first step in the process is to identify tools which will help you figure out what's
wrong.
{#r_DebuggingBusinessRules__table_ipc_pwl_jp__entry__2}

| Debugging tool | Description |
|-|-|
| System Dictionary | Navigate to System DefinitionDictionary. The dictionary provides a list of all tables within your instance and can be invaluable when trying to locate information. |
| System Log | Navigate to System LogsSystem Log. You can place alert statements in your business rule which can write information to the log. |
| Debug Business Rule (Details) | Navigate to System DiagnosticsSession DebugDebug Business Rule (Details). This debugging module displays the results business rules. Use this module to see if conditions are being met and values are being set as expected. |
| Alert Messages | There are several system functions that allow you to print messages to the page, the field or the log file. See [Scripting alert, info, and error messages](https://www.servicenow.com/docs/P4f2YDrzDFS7FOxIZJahng "You can send messages to users as alerts, informational messages, or error messages."). |
| Business Rule Examples | Sometimes you can find what you're looking for in scripts others have written, including business rule error messages, or by building an OR query. |
| GlideRecord Information | This is the basic syntax used to query the database for information. See [Querying tables in script](https://www.servicenow.com/docs/xPnZfVXvgKhseZybWHckSQ#c_UsingGlideRecordToQueryTables "Using methods in the GlideRecord API, you can return all records from a table, return records from a table that satisfy specific conditions, or return records that include a string from a single table or from multiple tables in a text index group."). GlideRecord also includes aggregation support. |
[Table 1. Debugging tools]

{#r_DebuggingBusinessRules__table_ipc_pwl_jp}

## 2. Variables

The next step is to gain some insight into the behavior of your business rule. For every
action except an insert, you will more than likely use a query to get your record(s).

    var rec = new GlideRecord('incident');
    rec.addQuery('active',true); 
    rec.query();
    while (rec.next()) {
     gs.print(rec.number + ' exists');
     }

To verify whether your query is actually returning records you can use
<var class="keyword varname">gs.addInfoMessage</var> to display information at the top of the screen.

    var rec = new GlideRecord('incident');
    rec.addQuery('active',true); 
    rec.query();
    gs.addInfoMessage("This is rec.next: " + rec.next());
    while (rec.next()) {
     gs.print(rec.number + ' exists');
     }

If your query returns no records you see the following:

    This is rec.next: false

Use this technique to verify every variable within your business rule contains expected
values.  
Tip:  
If necessary, break your script down into individual pieces and verify each piece works separate from the whole and then put them all back together one step at a time.

## 3. Locating information

The last step is to make sure you know where to find the information your rule is looking
for.

In the ServiceNow application, one
table can extend another table. This means when searching for information, you might need to
query the parent table for the extended table's sys_id to find what you seek.

A good example is the sc_task table, which extends the task table. The script below queries
the extended table (sc_task) for the current sys_id and then query the parent table (task)
for records with the matching sys_id, and then prints out the work notes field.

    var kids = new GlideRecord('sc_task');
    kids.query();
     
    gs.addInfoMessage("This is requested item number: " + current.number);
    gs.print("This is the requested item number: " + current.number);
     
    while (kids.next()) { 
     var parents = new GlideRecord('task');
     parents.addQuery('sys_id', '=', kids.sys_id);
     parents.query();
     
     while(parents.next()) {
      gs.addInfoMessage("This is task number: " + parents.number);
      gs.print("This is task number: " + parents.number);
      gs.addInfoMessage("These are the work notes: " + parents.work_notes);
      gs.print("These are the work notes: " + parents.work_notes);
      }
     
     }

*[\>]: and then


