My requirement is:
On create of an issue in JIRA, it should grab a particular value from the email address (say "domain_name" ), and based on that domain_name, search for all the issues that have the same domain_name. Then set the value of a custom field as fetched from the matched issues, in the created JIRA issue.
This is my code:
ComponentManager componentManager = ComponentManager.getInstance(); customFieldManager = componentManager.getCustomFieldManager(); IssueManager issueManager = ComponentAccessor.getIssueManager(); def public SupportPlan(MutableIssue issue) { ComponentManager componentManager = ComponentManager.getInstance(); customFieldManager = componentManager.getCustomFieldManager(); IssueManager issueManager = ComponentAccessor.getIssueManager(); def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction") User currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(); CustomField cfmail = customFieldManager.getCustomFieldObjectByName("Customer Email"); String cfmailV=(String)issue.getCustomFieldValue(cfmail); //Fetch domain name value def dmain_name = cfmailV.substring(cfmailV.indexOf("@")+1, cfmailV.lastIndexOf(".")); JqlClauseBuilder builder = JqlQueryBuilder.newClauseBuilder(); Query query = builder.customField(cfmail.getIdAsLong()).like(cfmailV).buildQuery(); SearchProvider searchProvider = ComponentAccessor.getComponentOfType(SearchProvider.class); SearchResults searchResults = searchProvider.search(query,currentUser,PagerFilter.getUnlimitedFilter()); List<MutableIssue> issues = searchResults.issues.collect {issueManager.getIssueObject(it.id)} for (def allIssues : issues) { String cfAIemailv = (String)allIssues.getCustomFieldValue(cfmail); String aidmain_name = cfAIemailv.substring(cfAIemailv.indexOf("@")+1, cfAIemailv.lastIndexOf(".")); if(dmain_name == aidmain_name) { CustomField cfSupport = customFieldManager.getCustomFieldObjectByName("Support Type"); String cfSTypeV =(String)issue.getCustomFieldValue(cfSupport); allIssues.setCustomFieldValue(cfSupport,cfSTypeV); } } } SupportPlan(issue);
I am not able to set the value to the custom field named "Support Type"
Pls help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.