We have a calculation based on different custom fields to show the business value of an issue. sadly the formula is not very performant. the formula is:
@Formula:
//Constants
var a = 0.3; // Strategical alignment (sa) and Revenue potential (rp) are weighted 30%
var b = 0.2; // Saving potential (sp) and competitive advantage (ca) are weighted 20%
var x = 2; // Is the factor for the weight of "business value" (bv) in the model
var y = 1; // Is the factor for the weight of the "loss of value" (lv) in the model
var z = 1; // Is the factor for the weight of the "capacity increase" (ci) in the model
//Variables for business value
int sa = (issue.get("customfield_11631") != null ? Integer.parseInt(issue.get("customfield_11631").toString()) : 0);
int rp = (issue.get("customfield_11632") != null ? Integer.parseInt(issue.get("customfield_11632").toString()) : 0);
int sp = (issue.get("customfield_11633") != null ? Integer.parseInt(issue.get("customfield_11633").toString()) : 0);
int ca = (issue.get("customfield_11634") != null ? Integer.parseInt(issue.get("customfield_11634").toString()) : 0);
var bv = (sa+rp)*a + (sp+ca)*b;
//Variables for loss of value over time
int lv = (issue.get("customfield_11635") != null ? Integer.parseInt(issue.get("customfield_11635").toString()) : 0);
//Variables for capacity increase
int ci = (issue.get("customfield_11636") != null ? Integer.parseInt(issue.get("customfield_11636").toString()) : 0);
//Variables for investment
int in = (issue.get("customfield_11637") != null ? Integer.parseInt(issue.get("customfield_11637").toString()) : 0);
//WSJF calculation
var wsjf = (x*bv + y* lv+ z*ci)/in;
return wsjf;
-->we thought about converting it to something like:
@Formula:
function q(e){return
issue.get(e)?+(issue.get(e)+""):0}return(2*((q("customfield_11631")+q("customfield_11632"))*.3+(q("customfield_11633")+q("customfield_11634"))*.2)+1*q("customfield_11635")+1*q("customfield_11636"))/q("customfield_11637");
-->
But then it's not working an the log is full of errors because obviously characters like the + or functions are not allowed.
Is there a solution to raise the performance or a documentation what kind of script (it's not real javascript, right?) we can try to use instead?
thanks in advance