Hi, community,
I have a script that I'm using that it'll display an error if the right person is not selected as an approver from the "Change Manger" drop-down field. It's working fine, the only issue is that whenever a user tries to create an issue it displays the first error message about the manager when the "Change Manager" field value is "None", which is the default value from Jira. Is it possible to not display an error when the value is "None"? I want to display the error message when there is a value. When it's none it should not display a message.
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def changeManager = getFieldById('customfield_19001')
def components = getFieldById(getFieldChanged()).getValue() as List<ProjectComponent>
if(components.any{it.name == 'Change Level1'}){
if (!(changeManager.value in ['User One', 'User Two'])) {
changeManager.setError("$changeManager.value is not a manager, please select a manager to approve the change")
} else {
changeManager.setError(" ")
}
} else if(components.any{it.name == 'Change Level2'}){
if (!(changeManager.value in ['User Three', 'User Four'])) {
changeManager.setError("$changeManager.value is not a director, please select a director to approve the change")
} else {
changeManager.setError(" ")
}
} else if(components.any{it.name == 'Change Level3'}){
if (!(changeManager.value in ['User Five', 'User Six'])) {
changeManager.setError("$changeManager.value is not a c-suite, select a c-suite to approve the change")
} else {
changeManager.setError(" ")
}
}
else {
changeManager.setError("please select a change approver from the list.")
}
Thank you,