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))
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're welcome - just curious, what was wrong?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.