Business Rules query

DanaWood
Tera Contributor

Morning,

 

I am new to ServiceNow and need help with Business Rules. Can I create before query based on catalog category?

if so how? 

 

\

5 REPLIES 5

Ct111
Tera Sage

You can do script something like below 

 

 

// Replace 'desired_category_sys_id' with the sys_id of the catalog category
var desiredCategory = 'desired_category_sys_id';

// Add a query condition to filter by category
if (current.isValidField('category')) {
current.addQuery('category', desiredCategory);
}

 

 

Name: Provide a descriptive name, e.g., "Filter Items by Catalog Category."
Table: Select the table on which the rule will apply (e.g., sc_cat_item for catalog items).
Active: Check the box to activate the Business Rule.
When to Run: Set When to Before and Insert to Unchecked (so it runs before querying).

 

 

I hope this sample helps

Juhi Poddar
Kilo Patron

Hello @DanaWood 

Yes, you can create a "Before Query" Business Rule based on a catalog category in ServiceNow. Here's how you can achieve this:

JuhiPoddar_0-1737953873696.png

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar

mihirlimje867
Tera Guru

Hello @DanaWood ,
 Yes, you can use the before business rule but make sure do not to use the current.update().

Thank you.

Ravi Gaurav
Giga Sage
Giga Sage

Hey @DanaWood 
Good Day !!
As mentioned by @Juhi Poddar  you can follow the same steps.. Additionally you can follow the below youtube video of mine..
https://youtu.be/NlCp5cMwCl4?si=4MTgW0jZX7HTFovm

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/