Hello Friends,
Need one help in setting default reporter for non-jira users in scriptrunner mail handler and select list field (Enviornment) default value is not working. Kindly help me in correcting my script :-
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.service.util.ServiceUtils
import com.atlassian.jira.service.util.handler.MessageUserProcessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
import com.atlassian.mail.MailUtils
def userManager = ComponentAccessor.getComponent(UserManager)
def projectManager = ComponentAccessor.getProjectManager()
def issueFactory = ComponentAccessor.getIssueFactory()
def messageUserProcessor = ComponentAccessor.getComponent(MessageUserProcessor)
def detail_description = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Detailed Description")
def envionment = getFieldByName("Environment")
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject(envionment.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
def optionToSelect = options.find { it.value == "Production" }
def subject = message.getSubject()
def body = MailUtils.getBody(message)
def issue = ServiceUtils.findIssueObjectInString(subject)
ApplicationUser user = userManager.getUserByName("vikrant-yadav2")
ApplicationUser reporter = messageUserProcessor.getAuthorFromSender(message) ?: user
def project = projectManager.getProjectObjByKey("HBBOP")
def issueObject = issueFactory.getIssue()
issueObject.setProjectObject(project)
issueObject.setSummary(subject)
issueObject.setCustomFieldValue(detail_description, body)
issueObject.setCustomFieldValue(envionment.setFormValue(optionToSelect.optionId))
issueObject.setCustomFieldValue()
issueObject.setIssueTypeId(project.issueTypes.find { it.name == "Bug" }.id)
issueObject.setReporter(reporter)
messageHandlerContext.createIssue(user, issueObject)
Thanks
V.Y
This may be doable, but I need to clarify: is this for a Service Desk project or a Software project?
If it is for the former, it may be doable if the sender's email address is already added to the Service Desk Customers.
However, if it is for the latter, I'm not so sure that it's doable.
Thank you and Kind regards,
Ram
Hi @Ram Kumar Aravindakshan _Adaptavist_ This is for JIRA Software. I am trying to setup default repoter for non-jira users.
Thanks
V.Y
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry Vikrant, I have no experience with the scriptrunner mail handler.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.