Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Custom field with multiple input fields

Stephan Miehe March 26, 2015

I'd like to build a custom field that gets populated by a user with a number. Javascript then pulls some data based on that number and populates two other fields that are then also saved to the DB. Those other two fields should be in the same view.

 

I've done this scenario before successfully without the need to populate other fields based on the input.

 

What's the best way to approach this?

 

 

6 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Stephan Miehe March 29, 2015

Got there in the end

0 votes
Stephan Miehe March 28, 2015

I kind of got this working now. I created one field called 'number' to capture the input from the user.

 

I then created another field called 'name' which runs the below code.

 

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.CustomFieldManager;
import groovy.json.*
CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager();
CustomField number = customFieldManager.getCustomFieldObjectByName("Number Field");
def data = new URL("Https://url.com"+number.getValue(issue)).getText();
def json = new JsonSlurper().parseText(data);

return json.name;

 

For the template I just used 'Text-field'

 

It works well but I want the 'name' field to update as soon as the 'number' field has been populated. Right now the 'name' field doesn't show until I save the issue.

 

Any suggestions?

0 votes
Stephan Miehe March 27, 2015

But how would it pull the data from the web service? The workflow is as follows:

 

  • User enters number into first field.
  • Once entered the number is submitted to a web service via ajax.
  • The returned JSON is evaluated and used to populate two other input boxes.

Does your recommendation allow for that functionality?

0 votes
GabrielleJ
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2015

In the "Create" transition, put 2 conditions "copy field from value to value"

0 votes
Stephan Miehe March 27, 2015

Will that allow me to populate the two other fields in the create view as soon as the value of the first field changes?

0 votes
GabrielleJ
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 27, 2015

You can use the JIRA Scripted Custom Fields and update your "Create" transition.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events