User IS NOT 'system'

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2019 03:19 AM
Hi,
I've got a new one for you.
Back before I joined this company and before I knew anything about ServiceNow, a partner of ours created some business rules. These rules are:
1. Gets user ID, checks if the company is MTI (i.e. internal user) and, if not, the query on the incident table is limited to only records that are associated with that users company. So, external users can only see records that were created against their company.
2. Gets the user ID and checks if the companyu is MTI (i.e. internal user) AND if the u_support_user tick box is ticked. If it isn't then that user can only see tickets that they have logged or where they appear in the watchlist.
Nice and easy and they work a treat.
However, if a notification is generated from a manually created incident and the notification calls the 'number' field, the task number is not displayed. If a notificaiton is generated from an automatically generated email then the task number is displayed.
ServiceNow traced this issue back to these business rules.
I think that, what is happening is that the notificaiton is trying to find the task ID but the user ID for notifications is "system" so it see's that the company name for this record is not MTI.
Does anyone have anyone have any ideas how I could amend this rule so that it dosn's exclude tasks when a notification is created?
Alternatively, can I amend the notification in some way to ignore this rule?
One of the rules:
Query = True
Before Query
(function executeRule(current, previous /*null when async*/) {
var u = gs.getUserID();
var user = gs.getUser();
var c = gs.getUser().getCompanyID();
if(c == 'f9d3dea36fc3b900f71fdece5d3ee42e' && (gs.getUser().getRecord().getValue('u_support_user') == false)){
var qc = current.addQuery('caller_id', u).addOrCondition('watch_list', 'CONTAINS', u);
}
})(current, previous);
All ideas welcome.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2019 08:31 AM
Is the email called from the incident table? How does the task field get called in the notification?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2019 01:57 AM
Hi,
Yes. The email is being generated from a workflow which is related to the task_sla table and measures 50%, 75% and 100% of SLA time before sending a notification email.
This is the activity defintion from the workflow "Notification" node:
We're using the same systax to call the task number as we would in any other notification.
It works for automated tickets (raised using "inbound mail rules") but not for manually created tickets.
Weirdly, I would have expected it to be the other way around because the BR's above filter if the user is not MTI. My expectation would be that the system says "you're not MTI and so you can't see this task number even in a notification".
It appears to be doing the opposite.