Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Setting Customer Request Type

Hello, i want to set the cutomer request type of an issue which is created by mail.
I use this code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.util.JiraHome
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)
JiraHome jiraHome = ComponentAccessor.getComponent(JiraHome)

def subject = message.getSubject() as String
def issue = ServiceUtils.findIssueObjectInString(subject)

if (issue) {

ApplicationUser user = userManager.getUserByName("admin")
ApplicationUser reporter = messageUserProcessor.getAuthorFromSender(message) ?: user
def project = projectManager.getProjectObjByKey("#####")
def customFieldManager = ComponentAccessor.customFieldManager
def optionsManager = ComponentAccessor.optionsManager
def issueObject = issueFactory.getIssue()

issueObject.setIssueTypeId(project.issueTypes.find { == "Softwareprobleme" }.id)

issue = messageHandlerContext.createIssue(user, issueObject)
def attachments = MailUtils.getAttachments(message)

attachments.each { MailUtils.Attachment attachment ->
def destination = new File(jiraHome.home, FileService.MAIL_DIR).getCanonicalFile()
def file = FileUtils.getFile(destination, attachment.filename) as File
FileUtils.writeByteArrayToFile(file, attachment.contents)
messageHandlerContext.createAttachment(file, attachment.filename, attachment.contentType, user, issue)

def crtField = customFieldManager.getCustomFieldObjects(issue).find{ == "Customer Request Type"}
issue.setCustomFieldValue(crtField, "#####/######")

But the customer request type is not set. What have i made wrong?
Kind regards

2 answers

1 accepted

0 votes
Answer accepted

I have find a solution.

with this code i solve the problem:

crtField = customFieldManager.getCustomFieldObjectByName("Customer Request Type")
def requestType = crtField.getCustomFieldType().getSingularObjectFromString("###/#####")
issue.setCustomFieldValue(crtField, requestType)
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)

Hi Jens,

Can you try.


def crtField = customFieldManager.getCustomFieldObjectByName("Customer Request Type")
issueObject.setCustomFieldValue(crtField, "######")



Hello Ortakatman,

thanks for your help, but the code is not the solution. The customer request typ is still empty.

Kind regards

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

394 views 3 17
Read article

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