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; -->
Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...
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