Hello All,
How to Set assignee based on User Picker custom field value on workflow transition.
For example:
S1 Admin(user Picker field)
is null, change the assignee to automatic assignee
automaticallyS1 Admin
is not null, change the assignee to S1 Admin
Thanks in advance,
Bunty
Hi @Bunty
Try this:
import com.atlassian.jira.component.ComponentAccessor
def cField = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("<user picker field name>")
def cFieldValue = issue.getCustomFieldValue(cField)
if(cFieldValue.name == null) {
issue.setAssigneeId('username')
}
if(issue.assignee==null) {
issue.setAssigneeId('username')
}
Regards,
Seba
I also got this error but it works. Did you run it?
If it not working please change it a little bit
import com.atlassian.jira.component.ComponentAccessor
def cField = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("<user picker field name>")
def cFieldValue = issue.getCustomFieldValue(cField).name
if(cFieldValue == null) {
issue.setAssigneeId('username')
}
if(issue.assignee==null) {
issue.setAssigneeId('username')
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import com.atlassian.jira.component.ComponentAccessor
def cField = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("<user picker field name>")
def cFieldValue = issue.getCustomFieldValue(cField)
if(cFieldValue == null) {
issue.setAssigneeId('username')
}
if(issue.assignee==null) {
issue.setAssigneeId('username')
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi. I'm trying a variation of the above, but cant get it to work. Can someone show me where I might be getting it wrong?
The custom field name is Responsible CA.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Eric Sebian what error/results did you get?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sebastian,
Is there any way to implement this code in an automation? I want to be able to update the assignee field based on a custom field when an issue is created. My scenario is I have service now tickets coming in with a custom field that allows the person opening up the ticket to identify an analyst that they are working with on the issue. That custom field in service now will be fed to a custom field in Jira instead of feeding into the assignee field. Is there a way to implement this code using an automation?
Thanks,
Kathy A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can achieve this in automation by using branches. Below example rule configuration.
Hope that will help you :)
Seba
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.