Forums

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

Scriptrunner - assignement in workflow

Arthur SALMON
Contributor
February 1, 2021

Hi Community,

 

I have scripts which are assigning users based on custom field values.

Those scripts are working and assigning the user but, for some reason, I have some users which are not correctly assigned and I don't know why.

 

For example, based on this script :

import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.comments.CommentManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.util.ImportUtils;
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager;
import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.user.UserUtils;
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption

def String m_assignee = 'Unassigned';
def cfIssueType = issue.issueType.name;

if(cfIssueType == "Task"){
def cfEntity = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Entity");
def cfEntitySwitch = issue.getCustomFieldValue(cfEntity) as LazyLoadedOption
switch(cfEntitySwitch){
case 'France':
m_assignee = 'john.doe';
break;
case 'US':
m_assignee = 'jack.jones';
break;
default:
m_assignee = 'john.smith';
break;
}
}
issue.setAssigneeId(m_assignee);

 In that script, users jack.jones and john.smith will be assigned replacing their username by the full name but for john.doe it's still the username which is display in the assignee field and because of that, the user is not notified and cannot execute the actions relatives to is assignee role.

 

Any idea why I have that ? 

 

Thanks in advance,

1 answer

0 votes
Martin Bayer _MoroSystems_ s_r_o__
Community Champion
August 18, 2021

Hi @Arthur SALMON , does john.doe have Assignable permission set?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.13.2
TAGS
AUG Leaders

Atlassian Community Events