Hi All,
I have created a script which allows to update a select list A by changing the value of a select list B. However, it is not working, please suggest:
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
FormField selectList1 = getFieldById("customfield_20650")
FormField selectList2 = getFieldById("customfield_20156")
def selectList1Val = selectList1.getValue()
if(selectList1Val.toString().contains("Australia")){
selectList2.setFormValue(17305)
}
error in logs:
java.lang.NullPointerException: Cannot get property 'customfield_20650' on null object
at com.onresolve.jira.groovy.user.FormField.getValue(FormField.groovy:181)
at com.onresolve.jira.groovy.user.FormField$getValue.call(Unknown Source)
at Script38.run(Script38.groovy:17)
What Am i doing wrong here? Please help
Hello,
The problem is that getFieldById("customfield_20650") returns null. Are you sure that you provide the correct id of the custom field and this custom field is present on the screen?
I am using this script inside the behavior plugin as a serverside script. Also, the field already has a value on the "View" Screen of the ticket and is mapped with the project and ticket type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Behaviours do not work with view screens. They work only with Create, Edit and Transaction screens. What screen do you open when you get the error? Are you sure the field is in that screen?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, the field is on the screen.
Thanks Alexey, I think the View screen is the issue here
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.