script to auto-populate a custom field based on the assignee

Micah Figone January 8, 2013

Does anyone know of a script of can assist in writing a script to run in a post transition to do the following?

Tickets have the "Assignee" and and a "Discipline" field. Have the "Discipline" field to be automatically set to a certain value based upon the role of the assignee of the ticket.

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Renjith Pillai
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.
January 10, 2013

If it's text, use this code

import com.googlecode.jsu.util.WorkflowUtils
  
def sourceFieldName = "assignee"
def targetFieldName = "customfield_10260"

def assignee = WorkflowUtils.getFieldValueFromIssue(issue, WorkflowUtils.getFieldFromKey(sourceFieldName))
def targetField = WorkflowUtils.getFieldFromKey(targetFieldName)

if(assignee = "person1")
{
WorkflowUtils.setFieldValue (issue, targetField, "value1")
}
if(assignee = "person2")
{
WorkflowUtils.setFieldValue (issue, targetField, "value2")
}
if(assignee = "person3")
{
WorkflowUtils.setFieldValue (issue, targetField, "value3")
}

JamieA
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.
January 10, 2013

I think that may be a little out of date. You can use do

issue.assigneId = "bob"

Use some business logic to work out who "bob" should be as in the example above.

Micah Figone January 10, 2013

This is a start. So the custom field is a select list populated with all of the roles for the project. The script should pull the role for the assignee and then set the custom field value to the one that matches their role for the current issues project.

0 votes
Renjith Pillai
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.
January 8, 2013
Micah Figone January 9, 2013

Yeah, I have that.... but I am not a developer and do not know hwo to write the script that would do what i want above.

Renjith Pillai
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.
January 10, 2013

What is the type of your custom field?

TAGS
AUG Leaders

Atlassian Community Events