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;
ComponentManager componentManager = ComponentManager.getInstance();
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager();
CustomField customField1 = customFieldManager.getCustomFieldObject('customfield_10589') ;
CustomField customField2 = customFieldManager.getCustomFieldObject('customfield_10590');
firstname = issue.getCustomFieldValue(customField1)?.getValue();
lastname = issue.getCustomFieldValue(customField2)?.getValue();
if (firstname && issue.summary){
if (issue.summary.contains(firstname) && issue.summary.contains(lastname)){
issue.summary = "Joiner:"+ issue.summary;
}
else{
issue.summary ="Joiner: "+firstname+" "+lastname;
}
}
else{
return false;
}
you need to update the issue after setting the fields.
where you are writing this script in workflow postfunction?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.event.type.EventDispatchOption;
import com.atlassian.jira.security.JiraAuthenticationContext;
ComponentAccessor comAcc=new ComponentAccessor();
CustomFieldManager cfm = comAcc.getCustomFieldManager();
CustomField customField1 = cfm.getCustomFieldObjectByName("FirstName");
CustomField customField2 = cfm.getCustomFieldObjectByName("LastName");
MutableIssue issue=(MutableIssue)transientVariables.get("issue");
String fname=issue.getCustomFieldValue(customField1).toString();
String lname=issue.getCustomFieldValue(customField2).toString();
if(fname.isNotEmpty()&&issue.getSummary.isNotEmpty()){
if (issue.getSummary.contains(fname) && issue.getSummary.contains(lname)){
issue.setSummary("Joiner:"+ issue.getSummary);
}
else{
issue.setSummary("Joiner: "+fname+" "+lname);
}
try{
JiraAuthenticationContext authContext = comAcc.getJiraAuthenticationContext();
comAcc.getIssueManager().updateIssue(authContext.getLoggedInUser() , issue, EventDispatchOption.EventDispatchOptionImpl.ISSUE_UPDATED , true);
comAcc.getIssueIndexManager().reIndex(issue);
}
catch(Exception e){
e.printStackTrace();
}
}
The above kind of Java code worked for me.
The issue should be Mutable Issue and also the customfield are of text type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It did not worked exactly because of lots of dependencies.. but it really helped in understanding a lot of new thing and Now I have developed a script of my own which is working as per the requirements.
Thanks a ton for all the Help.
Regards,
-- SR
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Still thinking about joining us for Team '25 Europe? Early bird has been extended for just one week! Now’s the time to lock in your lowest rate. Use code TEU25COMM-20 to save 20% at checkout. Hurry, this only lasts for 1 more week.
Learn more
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.