How to display a default text in a Custom Field through javascript whenscreen or form loads.

Hi JIRA Team,

I am trying to load a default value in a Custom Field(Textbox) by adding javascript code in description of that particular field. But the text does not appear in textbox. Could you please let me know how to do it. I tried below codes.

  1. <script type="text/javascript"> document.getElementById("customfield_13003").value = "HelloWorld"; </script>
  2. AJS.$(document).ready(function(){ AJS.$("#customfield_13003").val = "HelloWorld"; } );

Thanks in advance. 

1 answer

0 vote

Hey Aditya!

In order to run code on custom fields we normally use Script Runner. It's a very simple yet very popular plugin for JIRA those days and it can do lots of powerful things. Documentation for it can be found here and the plugin can be downloaded from Atlassian Marketplace here.

In order to display a simple text when loading the page, what you can do is install the Script Runner add-on, create a Custom Field setting its type to Script Field and, on the Add-ons tab of JIRA's Administration page, you can set the script you want to run on that field. 

information By the way, the Script Runner add-on uses Groovy as its programming language, so it's very easy to write code for it as it's very similar to Java.

There are lots of documents that can help you achieve great things over at the Script Runner documentation and I also tagged your question with the add-on's label, so that the developer may show up here and help you with that as he has much more knowledge of programming on there than us! wink



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

706 views 6 13
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