Total scriptrunner noob!
I have two dropdown fields that I am attempting to tie together one the create/edit screens. The idea is to allow a user to pick an option in either field, and the other field will populate immediately with the appropriate value.
Fields:
- SWID Name
- one one one
- two two two
- three three three
- SWID #
If / Then:
- If user selects SWID Name == "one one one"
then set SWID # == "111" - If user selects SWID Name == "two two two"
then set SWID # == "222" - If user selects SWID Name == "three three three"
then set SWID # == "333"
- If user selects SWID # == "111"
then set SWID Name == "one one one" - If user selects SWID # == "222"
then set SWID Name == "two two two" - If user selects SWID # == "333"
then set SWID Name == "three three three"
My script so far is just an attempt to get something super simple to work. Once I have the basic recipe, I'll build it up from there.
import com.atlassian.jira.issue.IssueInputParameters
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import com.atlassian.jira.component.ComponentAccessor
@BaseScript FieldBehaviours fieldBehaviours
def SWIDNumField = getFieldById(getFieldChanged())
String SWIDNumOption = SWIDNumField.getValue()
def SWIDNameField = getFieldByName("SWID Name")
if (SWIDNumOption == "111" )
{ SWIDNameField.setFormValue("one one one")
}
else if (SWIDNumOption == ("222") )
{ SWIDNameField.setFormValue("two two two")
}
else if (SWIDNumOption == ("333") )
{ SWIDNameField.setFormValue("three three three")
}
else
{
SWIDNameField.setFormValue("None")
}
Any help is greatly appreciated!
I have not found a good way of learning Groovy, besides attempting to solve problems like this. If there is a good course out there to logically learn how to groovy, I'm open learning and solving this on my own.