Using JIRA user properties to PREFILL (custom) fields on create

I've got a tricky question regarding JIRA user properties and am curious if anybody could send me in the right direction:

I'd like to store user properties (e.g. phone, department, hardware configuration, cost center, etc.) in JIRA and - now the tricky part - PREFILL an issue within the issue-create screen with these properties.

- I am familar with the concept of "how to prefill fields with javascript" (via field configurations)
- I do know, that there are several plugins (e.g. the JIRA Toolkit Plugin) which allow you to copy user properties to fields within POSTFUNCTIONS,

BUT the combination is currently the challenge.

Acceptance criteria:

1.) Only prefill content from user properties (granting reporter the possibility to overwrite them manually);
2.) Prefill in the create-screen (trigger "on create")

Anyone with a concrete idea will earn some karma points and my everlasting gratitude!

Cheers
Kai

4 answers

1 accepted

Hi. I recommend the Behaviours plugin (https://marketplace.atlassian.com/plugins/com.onresolve.jira.plugin.Behaviours). I used it to prefil the user Title field in an edit transition. Here is the snippet of code I used as the server side validation script. Worked in JIRA 5.1

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.user.UserPropertyManager
ComponentManager componentManager = ComponentManager.getInstance()
UserPropertyManager userPropManager = componentManager.getUserPropertyManager()

// Default values for Signee Name and Title
FormField formSigneeName = getFieldById("customfield_10460")
FormField formSigneeTitle = getFieldById("customfield_10553")
def currentUser = componentManager.jiraAuthenticationContext.getLoggedInUser()
formSigneeName.setFormValue(currentUser.getDisplayName())
formSigneeTitle.setFormValue(userPropManager.getPropertySet(currentUser).getString("jira.meta.title"))

Regards,

Chris

Hi Chris,

thanks for this answer. Although we had not installed the Behaviours Plugin so far, I did so right now and have to say: It works like charm and it is easy to set up. Many thanks! Well earned Karma-points!

Cheers

Kai

hi,

You can get the requested feature by using servlet and JQuery.

EX:

On a create screen you would want to prepopulate JIRA Custom Fields "Phone", "Department" from user properties (User may be reporter or user in usercustomfield or current user)

You can pass which user (User's whose properties need to be populated) as input to servlet (This can be done using java script and JQuery) - Sample url for servlet -http://xxx.xxx.com/plugins/servlet/servlettName?employee=yyyy

OR in the servlet code you can refer currentuser - Easy & simple

Then in the servlet code, you can fetch the properies related to required user.

Then from output/ servlet response, you can autofill the JIRA Customfields using script/ JQuery.

Note: You will have to call this servelt on any Field on the create screen using Jquery/ script

JIRA SERVLET MODULE - https://developer.atlassian.com/display/JIRADEV/Servlet+Plugin+Module

Thanks,

Chaithra

Hi Chaithra,

thanks for the quick response. Looks promising. I'll have a deeper look at it with a fellow frontend guy within the next two or three days. As soon as we'll have it running I'll come back with feedback (and will mark the question as solved).

Cheers
Kai

Hi Chaithra,

after having a closer look to your proposal I am doubtingabout the servlet-solution. For me it seems that I need to have a plugin or backend-script being written for that. Something which is deployed to the JIRA-server, right?

Honestly I was looking for any solution which uses javascript/JQuery only, to fetch custom user properties. Rationale is that we do not want to alter any layers in the backend of our JIRA instance. Hope I didn't get your proposal wrong.

Kind regards
Kai

PS: The properties shall be taken from "currentUser" alway.

Hi,

Yes, I meant you will have to write a servlet code.

We have written similar kind of servlet code & it is working fine.

Regards,

Chaithra

On 10/Apr/2013 we'll release JJupin 2.5.3. Our new functionality, LiveFields, will go out of the beta.

You will be able to manipulate the screen on create:

http://confluence.kepler-rominfo.com/display/JJUPIN/Accessing+the+current+screen

and you will be able to pre-fill the screen with your stuff (be there properties!)

http://confluence.kepler-rominfo.com/display/JJUPIN/lfSet

Getting properties from user should be pretty straightforward: http://confluence.kepler-rominfo.com/display/SIL/getUserProperty

If you can't wait, contact us and we'll provide you the snapshots :)

Hi Radu,

so far - having browsed the links for a few minutes - your plugin looks quite promising (I stumbled upon it already some time before). I'll have a second look at it and maybe it might be a solution. Nevertheless it is still a plugin-solution and might serve us, unless no other possibility without a plugin (jQuery/javascript + REST, etc) could be found.

Cheers
Kai

Hi Kai, just keep in mind that the release is on 10th of April. I understand perfectly, but in this case you can build your own plugin, add a rest resource to return the properties from the user (it's a 10 minutes job), and do whatever you like in JQuery (the disadvantage is again non-portability across JIRA versions).

Have fun,

Radu

Using Javascript and REST you can achive,

check this inbuild rest api

http://docs.atlassian.com/jira/REST/latest/#id165535

another way is you can develop your own REST plugin, check the doc

https://developer.atlassian.com/display/DOCS/REST+Plugin+Module

Hi Rambanam,

thanks for your proposal. As far as I can see there is a rest-call (GET) fro the user but no call for the user properties, or have I missed some information?

Kind regards
Kai

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

280 views 4 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you