My customer needs a read-only reference field based on JIRA issue key and create date showing only year and month.
Based on this example I tried to do it as shown below, but I get nothing back on the screen.
What am I doing wrong?
<!-- @@Formula: createDate=issue.get("created"); if (createDate ==null) return null; return "M/" +issue.get("issuekey") +string.Format("%tY-%tm", createDate, createDate); -->
thanks for any hints,
ps: JIRA v7.1.7 with misc custom fields addon v1.7.1
thanks for your answer! I tried it, but it did not help
where can I read about the syntax possibilities? I checked the addon documentation, but it did not provide list of syntax.
I could also use truncation (if such a function exists), eg: to get the year show only the first 4 characters
Is this possible?
The syntax is actually documented - or rather pointed to. It's http://www.beanshell.org/docs.html. It is a subset of Java.
As for why it doesn't work for you, the first thing you need to do is check JIRA's logfile (atlassian-jira.log) for errors. Look at the end of the file right after displaying an issue that should show the calculated field.
thanks for your pointers, I managed to solve it!
just for the record I add info below (maybe it helps others)
error in the log:
Sourced file: inline evaluation of: `` createDate=issue.get("created"); return String.format("%tY", createDate); ;'' : Error in method invocation: Static method format( java.lang.String, java.sql.Timestamp ) not found in class'java.lang.String' : at Line: 3 : in file: inline evaluation of: `` createDate=issue.get("created"); return String.format("%tY", createDate); ;'' : String .format ( "%tY" , createDate )
After some searching, I found this: http://stackoverflow.com/questions/6262570/how-to-retrieve-day-month-and-year-from-timestamplong-format
Based on this the below works fine:
<!-- @@Formula: createTimestamp = issue.get("created"); long timestamp = createTimestamp.getTime(); Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(timestamp); createYear = cal.get(Calendar.YEAR); return "M/" +issue.get("issuekey") +"/" +createYear; -->
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...
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!
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