I have a scripted field that only needs to return the toString value. Instead it returns the entire string value.
Here is the Script -
import com.atlassian.jira.ComponentManager
def componentManager = ComponentManager.getInstance()
def changeHistoryManager = componentManager.getChangeHistoryManager()
x = changeHistoryManager.getChangeItemsForField(issue, "Root Cause Primary")
if (x.join(' ') == "") {
return null
}
return x.join(' ')
When I run a preview it returns this string -
com.atlassian.jira.issue.history.ChangeItemBean@xxxxxxx[fieldType=custom,field=Root Cause Primary,from=,fromString=,to=1000005,toString=Business Configuration Data,created=2013-10-11 11:24:56.0]
How do I get it to return only the toString=Business Configuration Data?
The field should only show - Business Configuration Data
Thanks,
Andre
Community moderators have prevented the ability to post new answers.
You need to transform the collection of ChangeItemBean objects to collection of String.
Here's the code:
import com.atlassian.jira.ComponentManager
def componentManager = ComponentManager.getInstance()
def changeHistoryManager = componentManager.getChangeHistoryManager()
x = changeHistoryManager.getChangeItemsForField(issue, "Root Cause Primary").collect { it.toString }
if (x.join(' ') == "") {
return null
}
return x.join(' ')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.