I would like to set a new summary for all issues created from service desk. Now the summary is set automatically from service desk, I've added a script on "create" transition to test:
import com.atlassian.jira.issue.Issue Issue issue = issue; issue.summary = "new user: ";
his work fine.
But I want to concut the text with a value from Custome field (which is mandatory for "Create" transition: that is a validation rule) .This time it won't work.
I've tried on few ways:
import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.ComponentManager Issue issue = issue; CustomFieldManager customFieldManager = componentManager.getCustomFieldManager(); CustomField customField = customFieldManager.getCustomFieldObjectByName("Name of the new user"); if(customField.getValue(issue) != null) {issue.summary = "new user: " + customField.getValue(issue); }else{ issue.summary = "new user setup"; }
or with object id:
import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.ComponentManager Issue issue = issue; CustomFieldManager customFieldManager = componentManager.getCustomFieldManager(); CustomField customField = customFieldManager.getCustomFieldObject("customfield_10440"); issue.summary = "new user: " + issue.getCustomFieldValue(customField);
Also I've tried with:
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.ComponentManager
Issue issue = issue;
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager();
CustomField customField = customFieldManager.getCustomFieldObject(issue, "customfield_10440");
Object user = customField.getValueFromIssue(issue);
issue.summary = "New user: " + user ;
But nothing works fine.
Can you help me with that?
Thanks,
Kasia
Hi Katarzyna,
Do you use JIRA 7 ? If yes then the componentManager is deprecated you should use ComponentAccessor instead
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.MutableIssue MutableIssue issue = issue def customFieldManager = ComponentAccessor.getCustomFieldManager() def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Name of the new user'} issue.summary = "new user " + issue.getCustomFieldValue(cf)
But I think in your case a behaviour would be better. Actually I updated the code above (just add the custom script post function as the first post function during the create transition)
Hi Thanos,
Thansk for reply,
We are using JIRA 6.3.1 and Script Runner: 3.0.10. Is this script ok, for this version?
Regards,
Kasia
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.