Dynamic Username Filter in ServiceNow

Have you ever wanted to use a dynamic filter somewhere, where you do not have a reference to the User table? Yeah, so did I.

Here is how I did it.

Go to sys_filter_option_dynamic.list and create a new entry.

Complete it as follows, the idea we are going for here is matching our username to the sys_created_by field on the record.

Now copy the sys_id of the record you just created.

You are now able to use this dynamic filter anywhere that accepts script-based filters with the following format. This will also work against other string fields that capture usernames, such as sys_updated_by .

(Replace the sys_id below, following DYNAMIC with the sys_id of your filter record)

sys_created_byDYNAMIC36baa02edbd8515048e9dae2f39619f2

As I have done here in this widget configuration.

And that's it! You are now well on your way to dynamically filtering your custom table.