Brothers, Sisters
simple question. I am building transition Validator.
I need to write simple Groovy condtion. I have a customfield_11111 with possible values, "Yes" and "No".
My validator must check if customfield_11111 = Yes.
Thats it.... please, I know its dump question but I dive too deep probably instead of quick win,
This is what i achieved so far but with no results :(
import com.atlassian.jira.component.ComponentAccessor
def issue = issue // Bieżący problem w kontekście
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def field1 = customFieldManager.getCustomFieldObject("customfield_11111")
def value1 = issue.getCustomFieldValue(field1)
if (value1 = "Yes") {
return true // Walidacja przekracza
} else {
return false // Walidacja nie powiodła się
}
What app do you use for groovy scriptrunner or another workflow extension app.
For scriptrunner:
def customfield_11111 = issue.getCustomFieldValue('customfield_11111').toString()
hey,
thanks for quick reply. YES i am using ScriptRunner.
I update Transition and click "Validators-> Add Validator -> Fields Required Validator (JSWE app),
This is list of my AVAILABLE options:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So you are using the JMWE app?
In JMWE, you use the build your own validator option.
Then use groovy:
issue.get("customfield_11111") = "Yes"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ok so i did as u said
Descritpion: test
Error message: Field not "YES"
Choose type: Groovy script
Groovy script: issue.get("customfield_11776") = "Yes"
For Field: customfield_11776
And i get this error....
An error occurred while executing a Build-your-own Validator validator: startup failed: script_8a8649c80aab45e06411d1416129925c.groovy: 1: The LHS of an assignment should be a variable or a field accessing expression @ line 1, column 1. issue.get("customfield_11776") = "Yes" ^ 1 error Build-your-own Validator: root cause: startup failed: script_8a8649c80aab45e06411d1416129925c.groovy: 1: The LHS of an assignment should be a variable or a field accessing expression @ line 1, column 1. issue.get("customfield_11776") = "Yes" ^ 1 error
It seems that you have tried to perform an illegal workflow operation.
If you think you shouldn't get this message, please contact your Jira administrators.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Marc -Devoteam- is it relevant that my custom field is Radio Button type?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No this doesn't matter.
If custom field with id 11776 is a radio button field, the groovy on the validator should work with:
issue.get("customfield_11776") == "Yes"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.