I have a Field called "Domain" - need to make it required when it is not set to ReadOnly.
For specific workflow transition. Am trying to do this using "Field(s) required validator".
Am attaching the Screenshot for the same. Am not knowing if am doing the right way. Please guide me.
Your approach will not work because the method setReadOnly is only usable in the Behaviour and not in Validators.
For your requirement, why not just add a transition screen? And for that transition screen, you can use the Behaviour to set the field to required and editable. Using this approach, you can use Behaviour to validate to ensure that the value of the field is added.
Below is a sample code for your reference:-
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def sampleTextField = getFieldById(fieldChanged)
sampleTextField.required = false
sampleTextField.readOnly = true
if (actionName == 'Done') {
sampleTextField.required = true
sampleTextField.readOnly = false
}
Please note that the sample code provided is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a screenshot of the Behaviour configuration:-
Also, I have included a few test screens for your reference.
1. First, when creating a new issue, no value is added to the Sample Text Field, as shown below:-
2. Once the issue has been created, it will be transitioned to the Done status.
3. Once the Done button is clicked, the Done transition screen appears, and in it, the Sample Text Field is added. Now, the field is editable and is set to required, as shown below:-
4. If I try to close the issue without adding any value to the field in the transition screen, as expected, the validator returns an error message saying that the value for the field is required, as shown below:-
5. Once the value is added for the Sample Text Field on the transition screen, the issue can be transitioned to the Done status. Below you can see that the issue has transitioned, and a value has been added for the Sample Text Field.
I hope this helps to solve your question. :)
Thank you and Kind regards,
Ram
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.