Wednesday, February 20, 2008

Finally, a use for those JIRA user properties

One of the most useful JIRA plugins I've found is the JIRA Toolkit, described as "a bunch of neat custom fields Atlassian have developed for their own use". As an aside, if they're so neat and useful then why aren't they in the core product?

One of the more recently developed fields is the View User Property custom field, which is currently only documented in the issue that last link refers to. This handy little field allows you to display properties that you previously added to a user, as a read-only field in each issue.

For example, add a property named "Company" to some of your users in JIRA, then install the JIRA toolkit and create an instance of the View User Property field. Now configure it with "reporter:Company". Add the new field to some screens and the value of the reporter's Company field will show up in the issue. This also works with "assignee:Company". You can even get a user name with "My Custom Field:Company". This will use the user name found in the custom field named "My Custom Field". Just use the JIRA custom field name, including any spaces.

I've just used this to associate a company name with every customer user, and I'm sure there are a number of other pieces of per-user information that could be displayed with this field. One missing piece for this field is the ability to search for issues with particular values.

14 comments:

Anonymous said...

Bettina Zucker at http://confluence.atlassian.com/display/JIRAEXT/JIRA+Toolkit says that by modifying the plugin xml file and setting the searcher for the custom user property field, we can now search in User Property fields. Caveat: partial-text in the field cannot be searched.
I have done what Bettina said in jira-toolkit 0.7.30 and it works!

Matt Doar said...

The field is now called "User Property Field (< 255 characters)". To configure the field, set the Default value.

Matt Doar said...

Looking at the source for this field I see you can also use a custom field to get the user to search on. So you could have a field named "QA Contact" that contains a user, and then do a search for all users in that field who have a property location=San Jose.
I'm sure there are other uses for all this that haven't occurred to me yet.

Joanna Thurmann said...
This comment has been removed by the author.
Anonymous said...

Hello,

I just used this field to display a Desk location and Telephone number to help our support staff quickly locate the reporter.

On the linked page above the question is asked 'What to do if you have a 2 or more word property'
I just tested it, it works if you simply use the property exactly as displayed ie 'reporter:Desk Location' and does NOT work with reporter:Desk_Location'
Thanks, very helpful!
Stephquan

Matt Doar said...

Glad it worked for you. I should have been clearer that the field name should indeed be used exactly as it appears in JIRA, not with underscores for spaces. That was just part of an example.

Matt Doar said...

I updated the original post to make it clearer how custom fields can be used to get the user name.

Amit said...

Is it possible to use JQL on these user properties?

If so, what would a JQL query that wants to narrow results down by custom user properties look like?

Matt Doar said...

I think you'd have to write your own JQL plugin to do this. There's a good place to start at https://developer.atlassian.com/display/DOCS/Plugin+Tutorial+-+Adding+a+JQL+Function+to+JIRA or see some of the open source plugins.

Amit said...

Thanks!

But, I am (was?) willing to bet JQL had some hook into allowing a user to query on user properties (Jira calls it preferences, but that feels like a bit of a misnomer) like "jira.user.locale" (or other user properties). Is that not the case?

If nothing exists, I will build my own function and stick it online somewhere...

Matt Doar said...

I don't think JQL does have such a hook? But David Fischer has a good place for you to start with
https://studio.plugins.atlassian.com/wiki/display/JMCF/Home#Home-currentUserPropertyAsList

Amit said...

Ah, didn't see your post soon enough.

I ended up customizing the Jira ToolKit plugin to make it JQL enabled.

Caveats:

* JQL Function is named specific to my needs (VERY clear to end users)
* JIRA core (GlobalUserPreferencesUtil and its Impl) had to be customized. I couldn't find any other way to get users by their properties.

Amit said...

That brings up another question... is there a way for a plugin (Jira Toolkit) to customize the fields available in the Issue Navigator view?

So then, users can choose to see these 'User Properties' along side the reporter or assignee without having to click thru'.

Amit said...

Argh, nevermind my last comment. Had my head buried in the gravel too long.

Just had to create a custom field of type User Property Field (<255 Characters) and configure the default value to reporter:property_key. Some where above, another post details much the same.