Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to check Catalog Item from Business rule?

nannielf
Tera Expert

Hi all!

 

We have Business rule at sys_user table, that using "current.addActiveQuery()" if current user is not admin.

At one of our Catalog Items at Service portal we need to show all users, not only active.

 

Is there any solutions how to check where we are from BR? 

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

It sounds like you have a query Business Rule.  You can set your advanced reference qualifier to

activeANYTHING

preceded with a ^ if you are appending to an existing value.

In your query Business Rule, change the script to this, incorporating the admin check if that is in the script

(function executeRule(current, previous /*null when async*/) {
	var query = current.getEncodedQuery()
	if (gs.getSession().isInteractive() && !query.includes('activeANYTHING')) {
		current.addActiveQuery();
	}
})(current, previous);

View solution in original post

5 REPLIES 5

Hi! Thanks for your solution. It works, but only with one field. At my Catalog item fields autopopulate with script after filling in user name. With this solution inactive user is visible in "name" field, that has qualifier, but all other field are empty