How to two Javascript calculated custom field in eazybi

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

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
Community showcase
Published Oct 31, 2018 in Marketplace Apps

Marketplace Spotlight: Zephyr

Hello Atlassian Community! Each month, we run a series of Spotlights to highlight Marketplace vendors and apps that our team thinks this Community would find valuable. In last month's Spotlig...

335 views 0 1
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