setting the assignee based ona property key

sedasahinli@gmail.com September 4, 2013

Hello

How can I change the "assignee" in the post function of a transition "based on a custom field".

6 answers

1 accepted

1 vote
Answer accepted
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 4, 2013

using script runner plugin you can do this, sample code here just you need to do little bit changes as per custom field types

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
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.user.util.UserManager
import com.atlassian.crowd.embedded.api.User
// added line no.1
import com.atlassian.jira.component.ComponentAccessor
 
MutableIssue issue = issue
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
CustomField customFieldX = customFieldManager.getCustomFieldObject("Custom field x")
CustomField customFieldZ = customFieldManager.getCustomFieldObject("Custom field Z")
def xFieldVal = issue.getCustomFieldValue(customFieldX)
def zFieldVal = issue.getCustomFieldValue(customFieldZ)
   if(xFieldVal == "x" ){
   User userA=ComponentManager.getInstance().getUserUtil().getUser('person A')    
   issue.setAssignee(userA);
   }
if(zFieldVal =="t"){
User userB=ComponentManager.getInstance().getUserUtil().getUser('person B')    
   issue.setAssignee(userB);
}
issue.store()

check here for sample codes

https://jamieechlin.atlassian.net/wiki/display/GRV/Post+Functions#PostFunctions-Copyonefieldtoanotherusingregexp

0 votes
Coskun September 5, 2013

Hello, you can use the following ways for solution

Step 1 : The Field Assignee will take the value from yourcustomfield (with post function)

Step 2 : You can use the javascript codes. for yourcustomfield value selection.

<script>

var x = document.getElementById('customfield_999');

var y = document.getElementById('customfield_998');

x.onfocus=function()

{

switch(x.value)

{

.

.

.


}

}

like this...


Step 3 : using script runner plugin

0 votes
sedasahinli@gmail.com September 5, 2013

Thank you very much for your kind helps.

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 5, 2013

if something helped then don't forget to accept as a answer so it will help other user to choose right answer

0 votes
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 4, 2013

Or you need to write your own plugin with a workflow post function.

In the post function you can get custom field values and change the assignee of the user as Rambanam said.

Hi again,

JIRA Enhancer Plugin has a post function "Assign issue to a role based on a field in issue"

You can do such assignment using this plugin

Tuncay Senturk

0 votes
sedasahinli@gmail.com September 4, 2013

What I wanted to do is the following:

If the customfield x = y ,then assign to A person;

If the customfield z = t , then assign to B person.

0 votes
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 4, 2013

do you mean you have to copy value from custom field to assignee?

Suggest an answer

Log in or Sign up to answer