I am not sure that where I am going wrong on this is in the date section. I am trying to create a formula that will return a value based on the following formula.
Priority = (revenue/365)/(goal date - today)
Here is what I have but I am getting an error when the formula tries to calculate.
revenue = issue.get("Incremental Revenue")
days = 365
goal = issue.get("Goal Date")
today = new Date().format("yyyy-MM-dd")
if (revenue == null) return null;
if (revenue == 0) return 0;
if (goal == null) return null;
return (revenue/days)/(goal-today)
I am using a jira calculated field from JMCF
The problem stems from the fact that you are converting "today" into a String. It should be a Date, just like "goal". In that case, the "-" operator between two Date objects will return the difference in number of days.
Also, I'm not sure what you're calculating, but don't you want to multiply by the number of days between now and the goal date instead of dividing?
def revenue = issue.get("Incremental Revenue")
def days = 365
def goal = issue.get("Goal Date")
def today = new Date()
if (revenue == null) return null;
if (revenue == 0) return 0;
if (goal == null) return null;
return (revenue/days)/(goal-today)
That worked thanks. Is there a way to have the output not include anything after the decimal?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Two ways, depending on whether you want the value to retain the decimals (just not display them) or round up the value itself:
- use a Number Formatting script like:
numberTool.format(Math.round(value))
- round the value in the formula:
return Math.round((revenue/days)/(goal-today))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The second example with the Math.round on the return didn't seem to work. I'll try the formatting option, but I would rather have the actual result work as I am sure we will be exporting some of this data to confluence, where the formatting doesn't seem to work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, that was such a stupid answer on my part that I actually edited it out 😊
See the updated answer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you using JMCF 1.7 or 2.x?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.