Hi!
I have some question about groovy and jira. I want to copy component's description to custom field, if this component was chosen.
How can I get current component's description?
To get the current components descriptions as a comma separated list you can write
String componentsDescriptions = issue.componentObjects*.description.join(',')
I don't know groovy syntax but I have posted Java coding here. You can interpret in to groovy.
import com.atlassian.jira.bc.project.component.ProjectComponent; String compDescr=""; for(ProjectComponent comp : issue.getComponentObjects()) { compDescr = compDescr +comp.getDescription()+"\n"; }
CustomFieldManager cfm=ComponentAccessor.getCustomFieldManager(); issue.setCustomFieldValue(cfm.getCustomFieldObjectByName("<your customfield name>"),compDescr); // The issue should be mutable issue and imagining the customfield is of text type JiraAuthenticationContext authContext=ComponentAccessor.getJiraAuthenticationContext(); ComponentAccessor.getIssueManager().updateIssue(authContext.getLoggedInUser(),issue,EventDispatchOption.ISSUE_UPDATED,false); ComponentAccessor.getIssueIndexManager().reIndex(issue);
Hi Henning, how to null check it, if it's being used part of gStringTemplate engine
would the below work?
${issue.componentObjects*?.description.join(',')}
${issue.componentObjects*?.description.
join
(
','
)}
I don't think that you have to null check, if you use the *. operator. Did you have any problems?
Hi henning,
Iam using this expression as part of the email template using script runner built-in post function to send custom email
${issue.componentObjects*.name.join(',')} but it's not getting the component names.
It looks like you're new here. Sign in or register to get started.