Hey there!
I have problem with my script. The point is when an issue created, the summary of the issue should begins with the value of the "Customer" custom field. My script works in all transitions, but the create...
I've tried several ways.
I started with transientVars["issue"].summary. It based on Jamie's create sub-task script, wich I use at the create transition. I fill in the "Additional issue actions" field with the following:
issue.summary = "Some text - " + transientVars["issue"].summary;
And it works fine.
I've tried with issue changeholder too without any result (maybe it's my fault, I'm not a real coder).
My script wich works is the next (but not at create):
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption
//Issue issue = (Issue) transientVars.get(issue);
Issue issue = issue;
String FIELD_NAME = "Customer";
String SUMMARY_VALUE = issue.summary;
ComponentManager componentManager = ComponentManager.getInstance();
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager();
CustomField customField = customFieldManager.getCustomFieldObjectByName(FIELD_NAME);
if (customField != null) {
LazyLoadedOption option = customField.getValue(issue);
if (option != null){
String CUSTOMER = option;
String newSummary = CUSTOMER+" - "+SUMMARY_VALUE;
if (!SUMMARY_VALUE.contains(CUSTOMER)){
transientVars["issue"].summary = CUSTOMER+" - "+SUMMARY_VALUE;
//transientVars.get("issue").setSummary(newSummary);
//issue.summary = newSummary;
}
else{
return false;
}
}
else{
return false;
}
}
else {
return false;
}
The first post function is "Creates the issue originally." in the workflow.
Any idea, comment or help are appreciated.