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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Post function unable to set assignee using jython

Hi there,

I have a jython script in post function to look up a user from custom field "Product Lead" and set the assignee to that user on a workflow transistion. It was working fine previously. But with recent upgrade of Jira it is not working. Any changes needs to be done on this script?

from com.atlassian.jira import ComponentManager

from com.atlassian.jira.util import ImportUtils

from com.atlassian.jira import ManagerFactory

from com.atlassian.jira.issue.customfields.manager import OptionsManager

issueManager = ComponentManager.getInstance().getIssueManager()

customFieldManager = ComponentManager.getInstance().getCustomFieldManager()

optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager)

# See if the Program Lead has a value and set the assignee to that value

productLead = customFieldManager.getCustomFieldObjectByName("Product Lead")

if productLead.hasValue(issue) :


The error I get is on the last line " File "<string>", line 14, in <module> TypeError: setAssignee(): 1st arg can't be coerced to com.atlassian.crowd.embedded.api.User"

3 answers

1 accepted

0 votes
Answer accepted

Thanks this has been completed using groovy.

0 votes
Timothy Community Leader Jul 15, 2014

issue.getCustomFieldValue(productLead) is a string. You need to convert the result of that value to com.atlassian.crowd.embedded.api.User first.

Could you please provide me the exact lines to be added to conver the result of that value to com.atlassian.crowd.embedded.api.User as I am new to jython script.

Hi there,

New to Jython and New to the community 

I have a similar Jython script in a post function that takes the value from a User Picker custom field "Approval Required By" and sets the user as "Assignee" however this is an old script and we upgrading to JIRA 7.4.3 I am coming across the following error 

Error Message 
root cause: Traceback (most recent call last): File "/opt/orion-jira/jss/jython/workflow/", line 24, in <module> issue.setAssignee(getNextApprover(approvers).getDirectoryUser()) TypeError: setAssignee(): 1st arg can't be coerced to com.atlassian.jira.user.ApplicationUser  
from com.atlassian.jira.event.type import EventDispatchOption
import com.atlassian.jira.issue.Issue

componentManager = ComponentManager.getInstance()
commentManager = ComponentAccessor.getCommentManager()
customFieldManager = ComponentAccessor.getCustomFieldManager()

approversCustomField = customFieldManager.getCustomFieldObjectByName("Approval Required By")
approvers = issue.getCustomFieldValue(approversCustomField)

approvedByCustomField = customFieldManager.getCustomFieldObjectByName("Approved By")
approvedBy = issue.getCustomFieldValue(approvedByCustomField)

currentUser = getUser()
jiraAutomationUser = ComponentAccessor.getUserUtil().getUser('jira-automation')

if approvers is not None and len(approvers) > 0:
# For the first time when approvers list is created, i.e. when the approvers list is full and approvedBy list is empty, enter a comment so the list of approvers get notified.
if approvedBy is None:
commentManager.create(issue, jiraAutomationUser.getName(), "Your approval is required by the delegated authorities or has otherwise been requested. Please approve this ticket, if appropriate. Thanks.", True)


# Update issue before comment made so emails go to new assignee
issueManager.updateIssue(jiraAutomationUser, issue, EventDispatchOption.ISSUE_UPDATED, False)


Thanks in advance 

Suggest an answer

Log in or Sign up to answer

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