Scripted Field - Need to return only toString Value, not entire string

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

1 answer

1 accepted

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(' ')

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira Service Desk

Wy are we still using email for Service Desk workflows?

...attest to the experience of an urgent approval that gets lost in the boss’s inbox and requires that special “Please Approve” email or text message. In an age where we have distributed teams...

111 views 0 2
Read article

Atlassian User Groups

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!

Find my local user group

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

Groups near you