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

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

Cheers!

-Joao

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,323 views 14 20
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot