Prepopulate a custom field with text

I use this script to populate the Description field with my bug format:

<script type="text/javascript">
if (document.getElementById("description").value == "") {
document.getElementById("description").value = "Steps to Reproduce:\n1.\n2.\n3.\n...\n\nObserved:\n\nExpected:";
}
</script>

It works great. Now I want to populate one of my custom fields with some text and I tried using this script and it didn't work. I tried putting it in the description in the Custom Field itself and in a field configuration (where I really need it to be) but nothing so far has worked.

Does anyone know what I'm doing wrong?

JIRA 4.4

Thanks,

Kathy

7 answers

Hi Kathy,

Where did you place the JavaScript to populate your description field?

0 vote
Richie Gee Atlassian Team Mar 17, 2013

Hi Kathy,

About you replacing the description to the custom field, have you gotten the correct id of the custom field?

You can refer below for an example how to identify the customfield id:

https://confluence.atlassian.com/display/JIRA/How+to+change+Multi+Select+Custom+field+size+using+script

Or alternatively you can use firefox or chrome, right click and inspect element on the form itself to see what is the id of the custom field.

Hope this helps, do let me know if you need further assistant by commenting on my answer :)

Yes, I tried that also and it didn't help. I tried replacing "description" with both the custom field name and the ID and neither worked.

I don't have much JAVA experience so I wasn't sure if the "description" in the script was referring to the Description field itself or the little "d" description field within the Description field.

Commenting so Atlassian wil stop nagging me :-)

Hi Kathy,

Where did you place the JavaScript to populate your description field?

0 vote
Joe Pitt Community Champion Mar 10, 2014

Just a warning about user behavior. If you want to require the user to put data in the field and you prepopulate it with something it will meet the test of having data and the user won't be forced to update it. We tried something similar and MANY users didn't put anything in the field. They only filled in required fields.

Valid point Joe.

Im trying to achieve what Kathy has been able to achieve which is auto populating the decsription filed but I cant figure out where to insert the script she mentions above.

Any pointers?

0 vote
Joe Pitt Community Champion Mar 10, 2014

No. Being a COTS product we didn't mess with it except to install a couple of the long standing plug-ins. Management was bothered that fields without data didn't show when viewing issues so they forced us to enter default values. We ended up with issues closed with TBD in root cause, fixed version, and other fields because we couldn't force people to populate them. We ended up removing the defaults after a short time. We added required custom fields for things like steps to reproduce. The advantage of having seperate fields is you can search and sort them to identify trends.

This is not so much an answer as another way to get a similar result. In my JIRA instance I created three custom fields: Expected Result, Actual Result, and Steps to Execute/Reproduce. In "Steps to Execute/Reproduce" I made the default value for something akin to "#\n#\n#\n" so it would render an empty ordered list. I'm using JIRA as a test case repository as well as a bug tracker, so it's easy to copy the steps from the "Steps to Execute/Reproduce" field of a test case into that of a defect. 

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

616 views 6 12
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