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(',')
Hi Henning, how to null check it, if it's being used part of gStringTemplate engine
would the below work?
${issue.componentObjects*?.description.join(',')}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't think that you have to null check, if you use the *. operator. Did you have any problems?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you tried
<% out << issue.componentObjects*.name.join(',') %>
like shown in the example in the script runner docs?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Henning, Thanks it works now! :) but why was it not working with ${} and works with <%out %>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
is it because ${} is used only to show data already there in the bean and <% %> is used for minupulation/evaluation of data
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think it has something to do with the point in time when the expressions are evaluated. But I'm not sure.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.