Hi,
I have a custom field "Client" and another one "relevant entities".
When the field "Client" gets a specific value, let's say XX; I'd need that the "relevant entities" field to set a default value, YY.
I tried this code viaScript Runner-Behaviour plugin;
import com.onresolve.jira.groovy.user.FormField
FormField fieldClient = getFieldById("customfield_10112") def RelevantEntities = getFieldById("customfield_10367") def defaultValue = ("[10643]")
String client = fieldClient.getValue()
if (client.getvalue("[10297]") { //XX RelevantEntities.setFormValue(defaultValue) }
but it does not work. Any ideas please?
Thanks in advance for your help
Melissa
Hi Mel,
Assuming your Client and relevant entities fields are of the Select List type then you could use code similar to the example below in order to achieve your requirements above. The example below was created using JIRA 6.4 and Script Runner version 4.1.3.7.
import com.onresolve.jira.groovy.user.FormField // Get the custom fields by Name def fieldClient = getFieldByName("Client") def RelevantEntities = getFieldByName("relevant entities") // Get the value of the client field to test def clientVal = fieldClient.getValue() //The ID of the YY option on the relevant entities select list field int defaultVal = 10203 // If the value selected is XX then set the default value in the relevant entities select list if (clientVal =="XX") { RelevantEntities.setFormValue(defaultVal) }
I hope this helps
Thanks
Kristian
Hi Mel, I am glad the solution works. Thank you for accepting the answer. Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Melissa, What types your custom fields have ?
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.