Hello everyone,
I'm trying to create a server side behavior script, that has a condition to happen within a specific workflow action. (IE: Transition screen)
I want to "pull" in the value of the single select customfield "Client" from within the current issue, and compare it to a list of clients within the script.
If the correct client value is present, a single select customfield named "request type" becomes visible and required. Otherwise I want the "request type" field to default to not required and hidden.
Here is the script I currently have, but since the client field isn't within the transition screen, the value always defaults to "null".
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def clientField = getFieldById("customfield_13400")
def clientFieldValue = clientField.value.toString()
def requestTypeField = getFieldById("customfield_12001")
//Defines "required" fields. (If a field is Enabled it will be required)
def EnableField(FormField f) {
f.setHidden(false)
f.setRequired(true)
}
//Defines "hidden" fields. (If a field is Disabled it will be hidden & not required)
def DisableField(FormField f) {
f.setHidden(true)
f.setRequired(false)
}
//Defines which fields are "Enabled" / "Disabled" depending of option selected within 'Levels Of Effort' field.
switch (clientField.getValue()) {
case "Client1":
EnableField(requestTypeField)
break;
default:
DisableField(requestTypeField)
break;
}
Can someone please explain to me how I can grab the "clientField" value from within the issue without having it within the transition screen?
Thanks,
Mike