I'm trying to assign a user to a user picker custom field base on the value of another custom field (dropdown). For example, there are 4 values (Product, Customer, Support, Accounts) in a dropdown field. If the user selects "Product" the user picker custom field should have a user (George), if the user select "Support" from the dropdown then the custom user field should have the value "Parker". If user select other two options then it should have default value "Mark". I tried but some reason it is just picking the default user "Mark" for all selection. Any idea how to make it work? Following is my behaviour script. Thank you for your help.
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def custAssignee = 'mark'
def custField = getFieldByName("Inventory")
if(custField.value == 'Product') {
custAssignee = 'george'
}
if(custField.value == 'Support') {
custAssignee = 'parker'
}
def customerAssigneeFormField = getFieldById('customfield_11305')
customerAssigneeFormField.setFormValue(custAssignee)
Hi @Shah Baloch
try something like this (xxxxx needs to by replaced by id of your text custom field):
def userFormField = getFieldById('customfield_11305')
def textFormField = getFieldById('customfield_xxxxx')
Integer number = textFormField.getValue() as Integer
String user = number > 1000 ? 'kelly' : 'george'
userFormField.setFormValue(user)
I recommend you to insert this code as a server-side script to the text field (everytime you change this field you want to update the user field).
Still, I think it would be better to use number field instead of text field, if your users will fill in only numbers.
Hi @Shah Baloch ,
glad to help :-).
Would you please mark my answer as accepted? This action will mark the question as resolved and it can also help other users in the future to find the solution, if they have similar problems. Thank you!
Sorry, I thought this is question (not discussion), my last post doesn't make sense, ignore it, please :-).