kristin Posted March 14, 2023 Report Share Posted March 14, 2023 Hi there, I'm trying to add a custom attribute on User entities using the expression type and have read through this page. Even adding something simple like `{self.username}` doesn't evaluate - see attached image. Am I doing something wrong? My end goal is to gather the set of projects a user is assigned to. In python this being - `set(x['context']['project']['name'] for x in user['assignments'])`. This may be out of the scope of what expressions can do. But, we want to be able to add dashboard filters to only see users that are assigned to `x`, `y`, and `z` projects and can't do that currently. So adding a custom attribute to track a user's assigned projects is our workaround. Link to comment Share on other sites More sharing options...
Erik LaPlant Posted April 3, 2023 Report Share Posted April 3, 2023 Hi Kristin, Thanks for reaching out, and apologies for the delayed response. Unfortunately self if not supported for User Entities. That being said, you could always create a User Text custom attribute and map the variable used to query the projects the user has task assignments in. Example below is a direct change I made through the terminal. I'm sure you could wrap this into an Event Listener. user = session.query('User where username is "<ADD_USER_NAME_HERE>"').one() some_list = set(x['context']['project']['name'] for x in user['assignments']) new_list = ', '.join(some_list) user['custom_attributes']['<ADD_CUSTOM_ATTRIBUTE_KEY_HERE>'] = new_list session.commit() Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now