Comments on: Fixing the Fatal Flaw of Before Query Business Rules https://servicenowguru.com/business-rules-scripting/fixing-before-query-business-rules-flaw/ ServiceNow Consulting Scripting Administration Development Thu, 07 Mar 2024 17:25:48 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Mark Stanger https://servicenowguru.com/business-rules-scripting/fixing-before-query-business-rules-flaw/#comment-8062 Mon, 24 Apr 2017 15:08:41 +0000 https://servicenowguru.wpengine.com/?p=3137#comment-8062 In reply to Josh.

Only thing I can find on that is this ServiceNow KB article. Unfortunately, it looks like it’s just something that isn’t supported and I’m not sure of a current workaround.

https://hi.service-now.com/kb_view.do?sysparm_article=KB0564887

]]>
By: Josh https://servicenowguru.com/business-rules-scripting/fixing-before-query-business-rules-flaw/#comment-8061 Sun, 23 Apr 2017 23:44:04 +0000 https://servicenowguru.wpengine.com/?p=3137#comment-8061 Is there any mechanism of doing two sets of query conditions and combining them in a before query business rule?

We tried doing an encoded query and the ^NQ makes everything go bonkers – which we later found out was a ServiceNow issue but they consider it normal behavior.

Example:

We want to show all Incidents where a Sensitive flag is true and the user is the caller OR where a Sensitive flag is false and the user is a member of the currently assigned group.

]]>
By: Gregg Tolman https://servicenowguru.com/business-rules-scripting/fixing-before-query-business-rules-flaw/#comment-8060 Mon, 30 Jan 2017 17:25:19 +0000 https://servicenowguru.wpengine.com/?p=3137#comment-8060 Thank you Mark and Billy. We used a similar implementation, but explicitly set active=true and active=false in the sys_user reference qualifier. If those are both there then skip the addActiveQuery.

var encodedQuery = current.getEncodedQuery();
var indexActiveFalse = encodedQuery.indexOf('active=false');
var indexActiveTrue = encodedQuery.indexOf('active=true');
if (indexActiveFalse == -1 || indexActiveTrue == -1 ) {
	current.addActiveQuery();
}
]]>
By: Billy Matthews https://servicenowguru.com/business-rules-scripting/fixing-before-query-business-rules-flaw/#comment-8059 Fri, 11 Nov 2016 16:10:35 +0000 https://servicenowguru.wpengine.com/?p=3137#comment-8059 In reply to Mark Stanger.

There actually is a way to do this, though it’s a bit of a hack. On the OOB ‘user query’ business rule, change the script to the following:

if (current.getEncodedQuery().indexOf(‘allow_inactive=true’) != 0) {
current.addActiveQuery();
}

Then on any user references where you explicitly want to allow inactive users to be visible set the start of the reference qualifier to be ‘allow_inactive=true’. Because this attribute doesn’t exist the system essentially ignores this value (thought there’s a system property for strict glide record queries which may give you problems here if you have it enabled but it’s off by default) but we can still detect its existence in our Business Rule to accomplish our goal.

Now we can explicitly allow inactive users where we want them, without having to turn it off system wide.

]]>
By: Mark Stanger https://servicenowguru.com/business-rules-scripting/fixing-before-query-business-rules-flaw/#comment-8058 Mon, 21 Oct 2013 16:58:32 +0000 https://servicenowguru.wpengine.com/?p=3137#comment-8058 In reply to Troy.

The query business rule will override everything else so there’s not really a way to do what you’re looking to do unless you disable the business rule or allow other roles the ability to see inactive users. If you do that, then you would need to go back to your reference fields and add ‘active=true’ to every other place. That’s probably not very practical, but that’s what you would need to do unless you can adjust your process somehow.

]]>
By: Troy https://servicenowguru.com/business-rules-scripting/fixing-before-query-business-rules-flaw/#comment-8057 Mon, 21 Oct 2013 16:52:46 +0000 https://servicenowguru.wpengine.com/?p=3137#comment-8057 Hi Mark,

This solution works great in our instance! However, I do need to allow inactive users to be selected on one of our catalog items. A comment above stated inactive records can be seen, but not in ours. We have a condition on ours “gs.getSession().isInteractive()”. What would I add so this rule does not run on one specific catalog item? I’ve tried several conditions and can’t seem to get the right one. Thanks for your help!

Troy

]]>
By: sandy https://servicenowguru.com/business-rules-scripting/fixing-before-query-business-rules-flaw/#comment-8056 Thu, 10 Jan 2013 07:47:25 +0000 https://servicenowguru.wpengine.com/?p=3137#comment-8056 Hi Mark,
Sometime Process SLAs business rule (async) is getting triggered twice and creating duplicating rows in task_sla table.
I understood that this is happening because two instances of Process SLAs are created. Please can you tell me how to prevent this from happening and why is this happening.
We have a report based on SLAs and because of this issue we are getting duplicate data in that report.
Thanks so much for your help!
Sandy

]]>
By: Mark Stanger https://servicenowguru.com/business-rules-scripting/fixing-before-query-business-rules-flaw/#comment-8055 Fri, 01 Jun 2012 15:44:44 +0000 https://servicenowguru.wpengine.com/?p=3137#comment-8055 In reply to Andreas.

Great feedback! Hopefully we’ll see this fully implemented soon :).

]]>
By: Andreas https://servicenowguru.com/business-rules-scripting/fixing-before-query-business-rules-flaw/#comment-8054 Fri, 01 Jun 2012 15:08:45 +0000 https://servicenowguru.wpengine.com/?p=3137#comment-8054 In our production instance (build: 02-24-201_0902) the fix is still needed as the activity formatter displays only the sys_id instead of the e-mail address for a received e-mail. Also all referenced fields displayed as empty.

I also checked our dev instance (build: Aspen 04-30-2012_2149) and the fix is still needed for referenced fields; the activity formatter as well as the sys_email table show inactive referenced records properly.

Parallel tried it in a demo instance (build Aspen 05-18-2012_1143) and there it already works for the caller field but not yet for the opened_by.

Seems like it will be fully implemented soon but so far: Thx for the fix :)

]]>
By: Michael S https://servicenowguru.com/business-rules-scripting/fixing-before-query-business-rules-flaw/#comment-8053 Fri, 08 Jul 2011 21:35:33 +0000 https://servicenowguru.wpengine.com/?p=3137#comment-8053 This fix looks great. Just today I got tasked with looking into this issue.

]]>