Hi,
Having an issue with a similar code.
It's not auto assigning issues on creation using "Custom script post-function (inline script)" in the workflow post function.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.crowd.embedded.api.User
String user;
def cfManager = ComponentAccessor.getCustomFieldManager();
def cf = cfManager.getCustomFieldObjectByName('field name');
switch(issue.getCustomFieldValue(cf) as String){
case 'value 1': user = "email address";break;
case 'value 2': user = "email address";break;
}
issue.setAssignee(ComponentAccessor.getUserManager().getUserByKey(user))
However, results display confirmation copy of no failures:
I'm working within JIRA upgraded version 7.13.2.
Would it be possible for someone to provide advice on how to fix this?
Also, legacy script for auto-assignation is not working when placed in a new workflow, even though I've updated relevant custom fields and reference links. Does anyone know why this would be happening?
Thanks.
Hi
Have you tried to enable log? (see this article for details https://community.atlassian.com/t5/Jira-questions/Autocompletion-today-s-date-in-transition-Scriptruner/qaq-p/1110198#M353669)
From your code looks like your are using emails, not keys or usernames.
Try to use key/name instead of email, from jira api
getUserByKey(String userKey)
Returns an ApplicationUser based on user key.
getUserByName(String userName)
Returns an ApplicationUser based on user name.
Example:
user = "name.surname"
issue.setAssignee(ComponentAccessor.getUserManager().getUserByKey(user))
Hi Fyodor,
Thanks for suggesting the log and code updates. I can confirm the code works without the log and with email addresses. What seems to be happening is the custom field selected isn't working.
I've changed my target field to be one which is a Select List (single choice). This is showing that using a two tier list is causing the issue.
Do you know how to format the code to apply to custom fields which type is Select List (cascading)?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.