Copying comment value to description

Hi All, 

 

Im having abit of issue transferring a value to either a view only field (255 max character, i have more than this) or to a description of a customfield. 

Im currently pulling a comment value from specific per below code: 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue 
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.UpdateIssueRequest

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
MutableIssue issue = ComponentAccessor.getIssueManager().getIssueObject('TEST-429')


def userKey = "customer.care"
def commentManager = com.atlassian.jira.component.ComponentAccessor.getCommentManager()
def comments = commentManager.getComments(issue)
def lastCommentFromUser = comments?.findAll {it.authorApplicationUser.key == userKey}
def emailThread = lastCommentFromUser.last().body
def setVal = issue.setCustomFieldValue(customFieldManager.getCustomFieldObject(11803), emailThread)
		ComponentAccessor.getIssueManager().updateIssue(
            ComponentAccessor.getJiraAuthenticationContext().getUser()
            , issue
            , UpdateIssueRequest.builder().eventDispatchOption(EventDispatchOption.ISSUE_UPDATED).sendMail(false).build()
    )

return customFieldManager.getCustomFieldObject(11802)

Any help would be appreciated. 

 

Cheers, 

Pon

1 answer

0 votes
Vasiliy Zverev Community Champion Feb 26, 2017

Your code seems to be correct. What namely do you want to do? 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

26,906 views 2 7
Join discussion

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