I need to make a field read-only after transition to a status and above. To give you an inside, we have a flow going like(simplified):
1) Scope
2) Ready for dev
3) Dev
4)...
And after transition to Ready for dev I want a custom field to be set as read-only to prevent from any changes. I have tried to use below code but during testing it is not preventing from editing the field.
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FormField
FormField PlannedReleaseDate = getFieldById("23914")
def PlannedReleaseDateValue = (Date) PlannedReleaseDate.getValue()
def status = getFieldByName("status").getValue()
if( Arrays.asList("Ready for dev","Dev","UAT").contains(status) )
if (PlannedReleaseDateValue != null) {
PlannedReleaseDate.setReadOnly(true)
}
else {
PlannedReleaseDate.setReadOnly(false)
}