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

This widget could not be displayed.

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 Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published Jul 25, 2018 in Marketplace Apps

Jira Cloud and Bitbucket Cloud Integration with Microsoft Teams

One of the newest products in the Microsoft family - Microsoft Teams,  is a chat-based hub for teamwork that integrates all the people, content, and tools your team needs to be more engaged and ...

718 views 0 3
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