Debugging business rules
-
- UpdatedAug 1, 2024
- 3 minutes to read
- Xanadu
- Building applications
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.
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).
To verify whether your query is actually returning records you can use gs.addInfoMessage to display information at the top of the screen.
If your query returns no records you see the following:
Use this technique to verify every variable within your business rule contains expected values.
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.