How to two Javascript calculated custom field in eazybi

JinSeok, Heo September 3, 2017

I want to use two custom fields.

If you use the first custom field in the second custom fieldd, the wrong value appears.

Is there an order between custom fields?

This is the setting I want to use.




[jira.customfield_hdElapsedTime]
measure = true
data_type = "integer"
javascript_code = '''
var total = 0;
if(issue.fields.customfield_10301) {
var times = issue.fields.customfield_10301.completeCycles;

for (var i in issue.fields.customfield_10301.completeCycles) {
if (issue.fields.customfield_10301.completeCycles[i].elapsedTime) {
total += issue.fields.customfield_10301.completeCycles[i].elapsedTime;
}
}
issue.fields.customfield_hdElapsedTime = total;
} else {
issue.fields.customfield_hdElapsedTime = 0;
}
'''


[jira.customfield_hdDueyn]
dimension = true
data_type = "string"
javascript_code = '''
if(issue.fields.customfield_hdElapsedTime) {
if(issue.fields.customfield_hdType == "L1") {
if (issue.fields.customfield_hdElapsedTime <= ‪28800000‬) {
issue.fields.customfield_hdDueyn = "Y";
} else {
issue.fields.customfield_hdDueyn = "N";
}
} else if (issue.fields.customfield_hdType == "L2") {
if (issue.fields.customfield_hdElapsedTime <= 86400000) {
issue.fields.customfield_hdDueyn = "Y";
} else {
issue.fields.customfield_hdDueyn = "N";
}
}
} else {
issue.fields.customfield_hdDueyn = "N/A";
}
'''

 

1 answer

0 votes
Zane eazyBI Support
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.
September 20, 2017

Hi,

The order of the execution of JavaScripts for custom field calculations is not defined. 
We recommend avoiding reference from one JavaScript calculated custom field to another as it can give an unpredictable result. You would like to use all necessary calculations within a JavaScript calculated custom field relying on JIRA issue data only to get correct results. 

Regards,

Zane / support@eazybi.com

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events