Hi
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,
cheers,
gezza
ps: JIRA v7.1.7 with misc custom fields addon v1.7.1
Try String.format instead of string.Format.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
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; -->
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online 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.