You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Environment:
Problem:
We're using the canned scripted field Date of First Transition that ScriptRunner comes with. The field shows up correctly in Jira (UI, filter results, etc.) and the data comes through the JIRA REST API just fine.
However, when the scripted field is included in the Confluence macro Jira Issue/Filter, it shows up as $xmlutils.escapeForCdata($value.toString()) instead of a date/time value.
Steps to reproduce:
Please help, as this has become a major blocker for our reports.
Thanks,
Kamran Ansari
@Viacheslav Unfortunately, no.
I wish Adaptavist customer support was as good as their product, but unfortunately, this issue failed to get any traction from them. In the end, I had to implement a workaround which involved creating a string version of this scripted field using a Groovy script. So basically, we have two versions of the same field now:
1. Using Date of First Transition that is "JQL Date Time functions" friendly but NOT Confluence friendly
2. Using a custom scripted field that is Confluence friendly, but won't work with JQL.
Unfortunately, I won't be able to share the Groovy script with you, but you should be able to find plenty of examples online on how to walk the Jira issue change history to get to the bit of information that your Groovy script needs to return. The key is, you need to return the date/time string.
Hope that helps. If you do come across a better solution, I'd appreciate if you could post about it here, so others in the same boat could benefit.
Good luck!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok. Thank you for answer.
In my case - i have a field wich show version start date for issue
Template - date
here is a code
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.sql.Timestamp
import com.atlassian.jira.project.version.Version
Logger log = LoggerFactory.getLogger("Release Version")
log.info("Release Version started")
Version version = issue.getFixVersions()[0]
log.debug("Version: ${version}")
Timestamp result = (version)? version.getReleaseDate() : null
log.debug("Resuilt: ${result}")
log.info("Release Version ended")
return result
But in Confluence it shows
$xmlutils.escapeForCdata($value.toString())
So i create second field special for confluence jira issue macros
Template - text field
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.sql.Timestamp
import com.atlassian.jira.project.version.Version
Logger log = LoggerFactory.getLogger("Release Version")
log.info("Release Version started")
Version version = issue.getFixVersions()[0]
log.debug("Version: ${version}")
String result = (version)? version.getReleaseDate() : null
log.debug("Resuilt: ${result}")
log.info("Release Version ended")
def format1 = result
def format2 = Date.parse("yyyy-MM-dd hh:mm:ss", format1).format("dd.MM.yyyy")
return format2
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For what it's worth, it's not a problem with Scriptrunner, it's the way Jira serves up field data to Confluence. That's why you got no traction with SR support - there's nothing they can do to fix it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think you might have to fix this by changing the output of the scripted field.
I think you have selected a type of field which has formatting that relies on Jira's UI code to be rendered usefully for the users hitting the web interface, but Confluence does not know that this data needs to be rendered, it displays the physical data being returned.
So, you would either need to get Confluence to understand that it needs to do some rendering, or you have to simplify the output so that it does not need to be rendered and can be drawn out raw.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Nic,
Thanks for the quick turnaround on this!
To your point about fixing this by changing the output of the scripted field and simplfying it:
I don't know if that's possible, given that I'm using one of ScriptRunner's canned field called Date of First Transition, and I haven't been able to find a way to change its output via the field configuration dialog (the only way to interact with this field). All it lets me do is specify a Field Name, Field Description, Field Note, Issue Status, and Preview Issue Key. The Groovy code that the field is bound to is to be found nowhere.
More importantly though, the return data-type of the field is Date/time which both ScriptRunner and Confluence should be well equipped to handle, and I feel that changing it to a simpler type (such as string) would come with other undesirable effects (JQL date/time functions and comparison operators would probably no longer work, for example).
Thoughts?
Thanks!
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.