Selected option in comment

Tony Tify June 9, 2020

Hello Jira team,

When a user selects some option from drop-down list I want to appear it into comment field. 

Example:

Drop-down list with 5 options:

- Contractor "John"

- Contractor "Emily"

- Contractor "Mark"

- Contractor "Russel"

- Contractor "Sally"

 

A user selects "Contractor "Emily" from drop-down, comment fields updates and "Contractor "Emily" record appears into the field. 

 

Is there any plug-in or script? 

Please guys I need a help. 

2 answers

1 accepted

0 votes
Answer accepted
Tony Tify June 16, 2020

I found solution using Jython script. Here is:

 

from com.atlassian.jira.util import ImportUtils
from com.atlassian.jira.issue import MutableIssue
from com.atlassian.jira.component import ComponentAccessor
from com.atlassian.jira.issue.fields import CustomField
from com.atlassian.jira.issue.comments import CommentManager

issueManager = ComponentAccessor.getIssueManager()
issueFactory = ComponentAccessor.getIssueFactory()

user = issue.getAssignee()
ComponentAccessor = ComponentAccessor()
JiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext()
LoggedUser = JiraAuthenticationContext.getLoggedInUser()

userManager = ComponentAccessor.getUserManager()
customFieldManager = ComponentAccessor.getCustomFieldManager()

fldID = 'customfield_XXXXX'
#put your custom field number instead of XXXXX

fldFieldValue = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject(fldID)).getName()

comment = "Selected contractor is: " + fldFieldValue

CommentManager = ComponentAccessor.getCommentManager()
CommentManager.create(issue, LoggedUser, comment, True)

#Update search indexes
ImportUtils.setIndexIssues(True)
ImportUtils.setIndexIssues(False)

0 votes
Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 9, 2020

You will need some form of automation or scripting addon for this. A “listener”will have to listen for changes in that field and when modified a comment added. Here is a older thread that provides a good groovy script for similar question - Add-new-comment-with-new-field-value-when-field-is-updated 

Tony Tify June 9, 2020

An addon would ideal instead of scripting :) Unfortunately I didn't find any one. I found this similar solution https://confluence.cprime.io/display/TR/Show+custom+message+field+based+on+select+list+value, but it looks like inconvenient to use it if I have five and more options (20+ options). 

Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 9, 2020

Look at Automation for Jira. One of my favorite apps. It is now included in Cloud but not (yet) in Server.

Suggest an answer

Log in or Sign up to answer