The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Add Filter Condition - is (dynamic) not me

Dan Brown2
Kilo Sage

Hi, 

Quick question - in the filter conditions of a report, is there a way to add a dynamic filter of Assigned To is (Dynamic) Not Me?

thanks 

Dan 

1 ACCEPTED SOLUTION

Robert Ninness
ServiceNow Employee
ServiceNow Employee

I thought there should be a way to create a Dynamic Filter Option like this, but unfortunately it's not so easy. You can't just create one similar to the ME dynamic filter such as !gs.getUserID()

As mentioned above you would have to return a list of ALL users excluding the current user, which is overkill and would potentially overflow the filter character limit. There seems to be no way of changing the operator of a Dynamic Filter Option filter, it's always =.

However, you can instead use the javascript: notation on a regular filter to do something similar. e.g.

assigned_to!=javascript:gs.getUserID()

incident_list.do?sysparm_query=assigned_to!%3Djavascript%3Ags.getUserID()

Combining the two methods, is (Dynamic) One of my groups and javascript:gs.getUserID() you get something like the following:

assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744^assigned_to!=javascript:gs.getUserID()

incident_list.do?sysparm_query=assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744%5Eassigned_to!%3Djavascript%3Ags.getUserID()

Hope this helps.

~Robert

View solution in original post

9 REPLIES 9

Robert Ninness
ServiceNow Employee
ServiceNow Employee

I thought there should be a way to create a Dynamic Filter Option like this, but unfortunately it's not so easy. You can't just create one similar to the ME dynamic filter such as !gs.getUserID()

As mentioned above you would have to return a list of ALL users excluding the current user, which is overkill and would potentially overflow the filter character limit. There seems to be no way of changing the operator of a Dynamic Filter Option filter, it's always =.

However, you can instead use the javascript: notation on a regular filter to do something similar. e.g.

assigned_to!=javascript:gs.getUserID()

incident_list.do?sysparm_query=assigned_to!%3Djavascript%3Ags.getUserID()

Combining the two methods, is (Dynamic) One of my groups and javascript:gs.getUserID() you get something like the following:

assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744^assigned_to!=javascript:gs.getUserID()

incident_list.do?sysparm_query=assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744%5Eassigned_to!%3Djavascript%3Ags.getUserID()

Hope this helps.

~Robert

I recently ran into this situation and this helped me a lot.

I just would like to add that, in order to do this in a report, you have to select the related field "System ID" from the "Assigned to" so you can use the "javascript:" notation.

If you just select the field "Assigned to" in the filter of a report, the field transform in a way that are obligated to select a valid user from the sys_user table and, therefore, unable to type "javascript:xxx".

@Robert NinnessGreetings!

Will "assigned_to!=javascript:gs.getUserID()" work in a UI policy, too? I'm trying to make a field invisible to all users who is not the assignee. (Tokyo)

Thank you in advance!

Yes it will. Simply use the condition builder to create the condition: "Assigned to - is not" and then input the javascript javascript:gs.getUserID() into the input box.

Screen Shot 2023-01-13 at 5.10.34 pm.png

 Hope this helps

Used this today, thanks so much!