Hello!
We have the integration with the Jira-server and implement several calculated custom fields during data import (Advance settings).
One script == 1 additional custom field
Is it possible to create an array (i.e., hard coded or make one additional API call to get some additional data) and use this created array for all scripts?
please, could you explain it? or any workaround
Thank you ahead
Hi,
It is possible to use the common Javascript code section in the advanced settings to define variables that will be available for all Javascript custom fields.
I added the following code settings:
[jira]
common_javascript_code = '''
var global_array=["aa","bb","cc"];
'''
Now I can refer to this array in the Javascript custom field:
[jira.customfield_test_global]
name="Field 1"
data_type="text"
javascript_code='''
issue.fields.customfield_test_global=global_array.join(",");
'''
You can make the API call to create the global array with the getDocument:
[jira]
common_javascript_code = '''
var global_array=[];
result = getDocument( "/rest/agile/1.0/board/");
if (result && result.values) {
for (board of result.values) {
global_array.push(board.name)
}
}
'''
Note, however, the code will be executed for each issue during the data import runtime.
Kindly,
1 Like