Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Update multi select field based from email body


Can someone can help me on how to update multi select field based from the email body using scriptrunner email handler?

Jira data center

Vetrical field is multi select field


Email body

final String body = """This is a test body

Vertical: [ "option1","option2"]

Description: sample description



Appreciate your help on this

1 answer

0 votes

This is a script which is generally useless because it's a composite example - it shows you how to set a value of every type of standard custom field.

You should be able to extract the bits that refer to multi-selects quite easily

Hi @Nic Brough _Adaptavist_ 


I've already tried that one but I'm not sure how to pass the variable to select option.



Here's my Scriptrunner mail handler script


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.service.util.ServiceUtils
import com.atlassian.jira.service.util.handler.MessageUserProcessor
import com.atlassian.mail.MailUtils
import com.atlassian.jira.user.ApplicationUser
//This requires the name of the user that will trigger the Mail Handler
final def username = 'testuser'

//This requires the Project's Key that will be used for the Mail Handler
final def projectKey = 'EA'

//This requires the name of the Issue Type that will be used
final def issueTypeName = 'Story'

def userManager = ComponentAccessor.userManager
def projectManager = ComponentAccessor.projectManager
def issueManager = ComponentAccessor.issueManager
def issueFactory = ComponentAccessor.issueFactory
def messageUserProcessor = ComponentAccessor.getComponent(MessageUserProcessor)
def customFieldManager = ComponentAccessor.customFieldManager
def optionsManager = ComponentAccessor.optionsManager

def user = userManager.getUserByName(username)
//def issueReporter = messageUserProcessor.getAuthorFromSender(message) ?: user
ApplicationUser reporter = messageUserProcessor.getAuthorFromSender(message) ?: user
def project = projectManager.getProjectObjByKey(projectKey)
def subject = message.subject as String
def messageBody = MailUtils.getBody(message)

def cfVertical = customFieldManager.getCustomFieldObjectsByName('Vertical').first()

def issue = ServiceUtils.findIssueObjectInString(subject) as MutableIssue

if (issue) {

def issueObject = issueFactory.issue
issueObject.setIssueTypeId(project.issueTypes.find { == issueTypeName }.id)

def regex = /(?<=\[\[)([^\[\]]*)(?=\]\])/
def emailMatch = (MailUtils.getBody(message) =~ regex).findAll().first() as List
def VerticalEmail = emailMatch.first() as String

issue = messageHandlerContext.createIssue(user, issueObject) as MutableIssue


def fieldConfig = cfVertical.getRelevantConfig(issue)
def options = optionsManager.getOptions(fieldConfig)
def option = options.findAll { it.value in [VerticalEmail] }

issue.setCustomFieldValue(cfVertical, option)

issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH,false)

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

330 views 0 10
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you