EncodedQuery in Business Rule is not working

Community Alums
Not applicable

Hi - 

 

I am trying to restrict records based on model category and location. Here is the encoded query that works in filter query but when I try to apply this in Business Rule before query it doesn't work. It returns all records. This has to do something with using 'NQ' and it seems like it provides inconsistent returns. I tried changing it to "OR" but that doesn't work either. Please help. 

 

Spoiler
model_categoryNOT LIKEServer^locationANYTHING^NQmodel_categoryLIKEServer^location!=1f895fd8db2ff6004ad038f0ad9619b0

AngelThyagaraj_0-1671761693134.png

 

1 ACCEPTED SOLUTION

You may want to get the current query and then add the new conditions to it.

 

var enc = current.getEncodedQuery();

 

While adding, please ensure that the conditions are applied appropriately as otherwise it will end up returning all rows.

 

Thanks,

Arav

View solution in original post

10 REPLIES 10

SanjivMeher
Kilo Patron
Kilo Patron

Are you sure the condition satisfies and enters the script?


Please mark this response as correct or helpful if it assisted you with your question.

Community Alums
Not applicable

Yes, the condition works. I worked with different set of returns in the encoded query and it works. 

So NQ doesnt work. Also can you replace ANYTHING with u_parent!=

https://www.servicenow.com/community/developer-forum/how-to-write-query-business-rule-for-or-conditi...


Please mark this response as correct or helpful if it assisted you with your question.

Community Alums
Not applicable

sorry! Not sure how I replace with u_parent!=

 

The logic is to filter out all the servers with location X but show all other records including servers that will be anything other than location X.