Accessing a custom field value in velocity file from a java class Edited

Hi All, 

I have created a couple of custom fields. 

One is a TextCFType field, the other is a SelectCFType.

These are both rendered on create new issue page. 


My Goal:

Each time the TextCFType field value changes due to user input, I would like to pass the new value at runtime into a method located in a java class. Lets call this: This method will then use the value typed into the TextCFType field to query an external database. Once the results have been returned from this query I would like to populate the SelectCFType with these options. 

When new user input is created, I would like to completely overwrite the options within the SelectCFType. 


My Issue:

Having come from a Java and c# background I am not very familiar with javascript and client side programming. I do not know how to access the value of my TextCFType field each time the value is changed from my Java Method. 


So far I create a velocity variable at initialization called: $example.

This variable contains an instance of my Example class with several methods.

I have managed to add an "onChange" event to my TextCfType field so that when the user input is changed the following javascript function is called:

function calculateSelectOptions(){
var e = document.getElementById("$");
var text = e.options[e.selectedIndex].text;




When this method is called nothing happens. It does not seem as though I am able to pass the value of "text" to my method.

I have tried several different options including using a one of the setter methods of my Example class to change the 'value' attribute of the class with an external listener listening for changes in this variable. Nothing seems to work. 


Could someone please provide some guidance (or even better... a solution) on how this is achievable. 

0 answers

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

2,856 views 12 18
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