Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to auto assign issue based on Issue picker field

Nagaraju March 30, 2022

Hi Team

I have Issue picker field in Service Desk portal and when customer creating a ticket from portal they are selecting existing ticket from Issue picker field, then I need to assign this tickets to same from Issue picker.

 

Ex: I have a issue key A-100 and the same assign to (user1), when I am creating new ticket I selected A-100 from JIRA issue picker, so I need to assign A-101 ticket to (user1) automatically.

 

I written a script but its not working 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
// Set log level
def log = Logger.getLogger(getClass())
log.setLevel(Level.DEBUG)
final relatedIssueName = 'OCM Ticket'
def issuPickerField = getFieldByName(relatedIssueName)
def issuePickerFieldValue = issuPickerField.value

def userName = ComponentAccessor.issueManager.getAssignee(issuePickerFieldValue as String)
def user = ComponentAccessor.userManager.getUserByName(userName)
issue.setAssignee(user)

2 answers

1 vote
Anzar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 12, 2022

Please try this


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
// Set log level
def log = Logger.getLogger(getClass())
log.setLevel(Level.DEBUG)
final relatedIssueName = 'OCM Ticket'
def issuPickerField = getFieldByName(relatedIssueName)
def issuePickerFieldValue = issue.getCustomFieldValue(issuPickerField)

def user = ComponentAccessor.issueManager.getIssueByKeyIgnoreCase(issuePickerFieldValue.key).getAssignee()
issue.setAssignee(user)

Hope this works. Please accept the answer if it does.
Regards,

Anzar

0 votes
Aravind Koushik Gobburu
Contributor
March 30, 2022

Hi @Nagaraju try this with automation for jira plugin. Hope this works for you.

Suggest an answer

Log in or Sign up to answer