For sc_task table- Query Business Rule is not working as expected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I have written a query BR for "sc_task" table-where in I have used this encoded query "requestISEMPTY^opened_by.countryNOT INUT,UKA^NQrequestISNOTEMPTY^request.requested_for.countryNOT INUT,UKA"
The logic behind this : example--there are some sc_task without Request/RITM . I need to show the empty sc_task to all users which I restricted also. Below is the full code:
NQ" is not working as expected. Kindly please let me know how this can be achieved through encoded query?
var user = gs.getUser().getCountry();
// Restricted
if (user == 'CE|| user == 'KP') {
current.addEncodedQuery('requestISEMPTY^opened_by.countryNOT INUT,UKA^NQrequestISNOTEMPTY^request.requested_for.countryNOT INUT,UKA');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday - last edited yesterday
can you check this: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0564887
Also can you try like below:
(function executeRule(current, previous /*null when async*/) { var userCountry = gs.getUser().getCountry(); // Assuming 'CE' and 'KP' are the two-letter codes for your restricted countries. var restrictedCountries = ['CE', 'KP']; // Check if the user is in a restricted country. if (restrictedCountries.indexOf(userCountry) > -1) { // Build the query to show tasks with an empty request OR tasks where the requestor's country is NOT UT or UKA. var encodedQuery = 'requestISEMPTY^ORrequest.requested_for.countryNOT INUT,UKA'; // Add the encoded query to the current query.
current.addEncodedQuery(encodedQuery); } })(current, previous);
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
Thanks, GP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
there are issues when you use NQ in query business rule.
check the link shared by @G Ponsekar which explains the same.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader