Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to use arrays in a custom calculated field ?

Deleted user May 3, 2018

Hi,

I'm trying to use an array in a custom calculated text field in JIRA.

In order to do define a 2 dimension array like this :

myArray = [
     "priority1" => [1 => "val1", 2 => "val1", 3 => "val1", 4 => "val4"],
     "priority2" => [1 => "val1", 2 => "val1", 3 => "val1", 4 => "val4"],
     "priority3" => [1 => "val1", 2 => "val1", 3 => "val1", 4 => "val4"],
     "priority4" => [1 => "val1", 2 => "val1", 3 => "val1", 4 => "val4"],
     "priority5" => [1 => "val1", 2 => "val1", 3 => "val1", 4 => "val4"],
]

And using it like :

myArray[issue.get("priority").name][issue.get("customfield_12345")]

 I found several example that I tried unsuccessfully :

def myArray = ["ABCD", "EFG", "HIJK"]

or

String[] list1 = [request_type1, request_type2, request_type3]

Does anyone has an example for me in this context ?

5 answers

1 accepted

0 votes
Answer accepted
Deleted user May 4, 2018

Actually on the wrong way since the beginning. ^^

I had to import and use the HashMap class !

<!-- @@Formula: 
import java.util.HashMap;
list = new HashMap();
list.put("key", "value");
return list.get("key");
-->
0 votes
Deleted user May 4, 2018

I need keys to make an associative array, now... but I can't find examples for now...

0 votes
Deleted user May 4, 2018

And... That's it !

<!-- @@Formula: 
array = new int[][] {{2,3},{4,5}};
return array[1][0];
-->

Ir works ! :)

0 votes
Deleted user May 4, 2018

I finally got it for a one dimension array :

a = new int[]{1, 2, 3};

 Trying with String[] and multidimensional arrays, now...

0 votes
Deleted user May 4, 2018

I have just tried it too :

def fieldid = new String[5];
fieldid[0] = 10513;
fieldid[1] = 12906;
fieldid[2] = 12911;
fieldid[3] = 12907;
fieldid[4] = 12908;
return fieldid[4];

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events