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

This widget could not be displayed.

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 Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

286 views 5 0
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