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.

20 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.

Unknown said...

The updated link for the JTOOL-37 issue is at https://ecosystem.atlassian.net/browse/JTOOL-37

Anonymous said...

Picked up this blog when I searched for an issue i'm having with the User Property Custom Field via JIRA toolkit. I've set the default value to be reporter:Phone and it's not showing up in my create screen or populating the view screen with any information. It's showing the the field, but the value is blank.

I would love if I could get this field to show user property information on the create screen. We're using this information with JIRA service desk and if we could see the user's phone number we could then just validate instead of typing it in.

Any thoughts on this would be very appreciated.

cmcardle@delawarenorth.com

Matt Doar said...

Collin,

Actually, I'm not sure how Service Desk and the Toolkit field interact. Did you add a Phone property key and a value to the issue where the user is the reporter? And which version of JIRA and the Tookit are you using? It's not a supported add-on so I wouldn't expect too much from Atlassian Support on this.

~Matt

Unknown said...

I am SO HAPPY i found this thread... here is what i am trying to do...

I have set 4 user properties for each user in JIRA. EmployeeRole, EmployeeStatus, Supervisor, and ResourceCostCenter.

I have no problem getting these fields to display the values that i set in each user property.. but the problem is, i need to view these user properties next to each worklog that each user logs on issues..

does that make sense? let me give an example..

i need to report on each user the following:

the issues that user LOGGED WORK on.
the amount of TIME LOGGED as well as the WorkLogAuthor ResourceCostCenter (which is a user property)

how might i go about doing this? can i do it without an add-on?

please help!!!!

thank you.

Matt Doar said...

Josh, I don't think you can do this without an add-on. Tempo Timesheets, or custom scripts with ScriptRunner are the two approaches that occur to me.

Matt Doar said...

Note that to add a property, you have to be in jira-administrators