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:";

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



7 answers

Hi Kathy,

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

0 votes
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:

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 votes
Joseph 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 votes
Joseph 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
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,260 views 5 10
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