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: Example.java. 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("$customField.id");
var text = e.options[e.selectedIndex].text;

$example.updateSelectOptions(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. 

1 answer

@Jlamb250194, any luck with this?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Monday in Jira Software

Implementing Jira in Small Business

Introduction This article will give insight on how a small software development department implemented Atlassian products to enhance and streamline the business process. The privately held company h...

316 views 2 8
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