Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Assigning assignee automatically using post function

Hi,

I have a request type Training, where I want the reporter who creates the ticket(say Lead) to assign the assignee(say New joiner to the team) while creating a ticket in Service Desk. So, I'm using a custom field 'Trainee' in the service desk form and using the post function copy the field value from Trainee to 'Assignee' and then remove the field 'Trainee' from the ticket by setting the value to None. It didn't work. 

Then I tried with the Script runner Post function.

Both the custom fields are 'Single User Picker'. I used the below script. If this is not correct, please help me with correcting where I'm going wrong.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()

def cField = customFieldManager.getCustomFieldObject("Trainee")
ApplicationUser user = issue.getCustomFieldValue(cField) as ApplicationUser
UserManager userManager =   ComponentAccessor.getUserManager();
issue.setAssignee((user))

 

2 answers

1 accepted

0 votes
Answer accepted

I got this sorted out. 

JIRA doesn't let you change system fields (such as the Assignee field) after the "Creates the issue originally" post-function.

So you should either move the post-function for setting assignee to before the "Creates the issue originally" post-function, or if you can't, your only option is to use the "Transition Issue" post-function to trigger a hidden auto-transition that will update the assignee field.

I was able to move my Post function to copy the field value from Trainee to Assignee and it worked..

Does this need to be done with Scriptrunner?  do you have any other plugins, like JSU?

Yes, I do have JSU.. What do you suggest...??

Hey @Rob Horan , Thanks for your support, I have sorted out where was going wrong.

You're welcome - just curious, what was wrong?

I read somewhere in an Atlassian document that JIRA doesn't let you change system fields (such as the Assignee field) after the "Creates the issue originally" post-function.

So you should either move the post-function for setting assignee to before the "Creates the issue originally" post-function, or if you can't, your only option is to use the "Transition Issue" post-function to trigger a hidden auto-transition that will update the assignee field.

I was able to move my Post function to copy the field value from Trainee to Assignee and it worked..

 

Like Rob Horan likes this

Hmmmm, that's interesting, because I am 99% sure that I've made a ton of post functions in which assignee updates happened after the create issue originally post function happened, but now I need to look :)

@Rob Horan I was also wondering the same until I tried...  Found the link where i read it... https://community.atlassian.com/t5/Answers-Developer-Questions/Post-Function-Order-Trying-to-Set-Assignee-Based-on-Field/qaq-p/512759

Check out the answer given by David.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

290 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you