Hi Team , There is one requirement from my side where I am stuck -> Via Incoming Mail handler , I want whenever the mail is sent to particular mail id the ticket would be created but in the project workflow the component/s is set as mandatory in validator , so whenever the mail is sent the incoming mail handler would be scripted in order to set the component/s by default as "test" since component is a system field as well an array I am not getting the function to set it.
Here is my code, could you please help me to set the Reporter who is sending the mail and assignee a particular mail and the component as "TEST"
CODE :
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.service.util.handler.MessageUserProcessor
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.ApplicationUsers
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.MutableIssue
import java.util.regex.Pattern;
import java.util.regex.Matcher
import com.atlassian.jira.workflow.TransitionOptions
def issueService = ComponentAccessor.getIssueService()
def userManager = ComponentAccessor.getComponent(UserManager)
def projectManager = ComponentAccessor.getProjectManager()
def issueFactory = ComponentAccessor.getIssueFactory()
def messageUserProcessor = ComponentAccessor.getComponent(MessageUserProcessor)
def project = projectManager.getProjectObjByKey("TESTJIRA")
ApplicationUser user = userManager.getUserByName("abcd")
def issueObject = issueFactory.getIssue()
issueObject.setSummary("Test TPO")
issueObject.setDescription("Test Description")
issueObject.setIssueTypeId(project.issueTypes.find { it.name == "Service Request" }.id)
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Components")
issueObject.setCustomFieldValue(customField,"TEST")
messageHandlerContext.createIssue(user, issueObject)