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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

352 views 0 6
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