I'm trying to use Behaviours plugin to set default value for some custom fields when create issue.
I created Behaviour and added script
import com.atlassian.jira.component.ComponentAccessor
def tasksFld = getFieldByName("Tasks")
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject(tasksFld.getFieldId())
def defaultValue = """[Tasks|https://]""".replaceAll(/ /, '')
if (getFieldScreen().name == "RM CreateScreen 2.0") {
tasksFld.setFormValue(defaultValue)
}
but I did not get needed result - seems like condition
getFieldScreen().name == "RM CreateScreen 2.0"
never works. It does not put value to field when issue created and screen "RM CreateScreen 2.0" is used.
Am I doing something wrong?
Maybe there is another method to restrict behaviours only for create issue operation? Or don’t overwrite the custom field if it already exists?