get first assignee

I want to assign my task to first assignee if re-open by some other user.

1 answer

This widget could not be displayed.

Whilst this is not possible without the use of Add-ons it is relatively staightforward with Add-ons. You need to capture the username of the first assignee (possibly in a hidden field) and then on the transition for re-open set the assignee field to match the hidden field content. 

Depending on which Add-ons you already have installed it may even be the case that you have the functionality already in place. 

Consider the following options (and there are more) to see which is the best fit for you.

https://marketplace.atlassian.com/plugins/com.onresolve.jira.groovy.groovyrunner/server/overview

https://marketplace.atlassian.com/plugins/com.innovalog.jmwe.jira-misc-workflow-extensions/server/overview

https://marketplace.atlassian.com/plugins/com.fca.jira.plugins.workflowToolbox.workflow-toolbox/server/overview

 

Thanks Phill, I have added following code under "Post function" but still not working. Please let me know if something is missing in code.

----------------------------------

import com.atlassian.jira.issue.*

import com.atlassian.jira.issue.fields.CustomField

import com.atlassian.core.util.DateUtils

import com.atlassian.jira.ComponentManager

import com.atlassian.jira.issue.history.ChangeItemBean

 

def componentManager = ComponentManager.getInstance();

def changeHistoryManager = componentManager.getChangeHistoryManager();

 

def changeItems = changeHistoryManager.getChangeItemsForField(issue, "assignee");

def firstAssigned;

def assigneeName;

if(changeItems !=null && !changeItems.isEmpty()){

    ChangeItemBean ci = (ChangeItemBean) changeItems.get(0);

    assigneeName = ci.getFrom(); // name

    String assigneeFullName = ci.getFromString();// full name

        def assignedTime = ci.getCreated().getTime();

        firstAssigned = assignedTime;   issue.setAssigneeId(assigneeName.toString())

}

You need to set the assignee as User object, not a display name or login id.

Thanks Nic. I removed toString function from last line and it work according to my requirement.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted yesterday 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...

59 views 2 3
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