assign to a user in field if exsting

Hello, I have a field called-Solution provider and I want to write up a script in post transition

if (solution provider != null)
	assign to solution provider

 

can someone share how to do it?

 

1 answer

This widget could not be displayed.
Vasiliy Zverev Community Champion Mar 10, 2016

Here is a code example 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField

CustomField customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Сложность")
if(customField != null)
    issue.setAssignee(customField.getValue(issue))

There is not update issue funciton since there is special step for it into post function list.

Hello, Vasiliy,

Can you help me with this issue?

I got error message from log:

2016-03-15 22:15:57,585 http-bio-8443-exec-10547 ERROR jessy_li 1335x2042069x2 1748upc 10.1.75.160 /secure/WorkflowUIDispatcher.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: TCD-155, actionId: 11, file: <inline script>
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.IssueImpl.setAssignee() is applicable for argument types: (com.atlassian.jira.user.DelegatingApplicationUser) values: [jason_tong(jason_tonger)]
Possible solutions: setAssignee(com.atlassian.crowd.embedded.api.User), getAssignee(), setAssigneeId(java.lang.String), getAssigneeId()
at Script21.run(Script21.groovy:7)

 

Vasiliy Zverev Community Champion Mar 15, 2016

Try this one:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
 
CustomField customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Сложность")
if(customField != null)
    issue.setAssigneeId(customField.getValue(issue))

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted 11 hours ago in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

30 views 1 2
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you