Making ‘assigned to me’ views and other uses of your username

Using a text field option, it’s possible to assign system users to records, so for example if you have a ‘todo’ list, items can be parcelled out to individual people.

There’s now an easy way of creating a view that filters based on the currently logged in user, a ‘my items’ view if you like. The facility that allows this is actually a bit more generic – it’s the ability to use the username of the logged in user in any calculation. Just add the code


and when the view is looked at, the name of the current user will be used instead, in the format ‘Firstname Surname (username)’, the same format used when assigning users to records.

So to create the ‘my list’ example, you could add a boolean calculation like

assigned to me = {assigned to} ilike current_setting('ab.userid')

or if a record can be assigned to more than one person via a tags field,

assigned to me = {assigned to} ilike '%' || current_setting('ab.userid') || '%'

which will find any records containing the currently logged in user. Then just add a filter ‘assigned to me = true’ and the list will auto-filter whenever a user looks at it.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: