Prepopulate a custom field with text

Kathy Tempesta March 17, 2013

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

8 answers

3 votes
Darren Campbell March 10, 2014

Hi Kathy,

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

0 votes
Suraj Gupta July 15, 2020

Hi Kathy, I am looking to implement the Description with Bug Format. Can you share the steps for the same. That would really help me

0 votes
Logan G Hawkes
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 10, 2014

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. 

0 votes
Joe Pitt
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 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.

0 votes
Joe Pitt
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 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.

Darren Campbell March 10, 2014

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
Darren Campbell March 10, 2014

Hi Kathy,

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

0 votes
Kathy Tempesta April 1, 2013

Commenting so Atlassian wil stop nagging me :-)

0 votes
richie_gee
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 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 :)

Kathy Tempesta March 18, 2013

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.

Suggest an answer

Log in or Sign up to answer