Hi
I'm trying to set up a behaviour in scriptrunner which marks the field assignee as required when the security level has been changed to a specific one.
I've added the field Security Level to my behaviour and mapped it accordingly to our projects and issue types. I've also added a serverside script:
def childField = getFieldById("assignee") def parentField = getFieldById(getFieldChanged()) def selectedOption = parentField.getValue() as String if(selectedOption == "Autor, Bearbeiter & Beobachter") { childField.setRequired(true) } else { childField.setRequired(false) }
image2016-8-25 16:14:28.png
However, the field is not marked as required when I set the security level.
Can somebody help me here?
Thanks and best regards
Marius
The values of the Security Level field have their own manager that you'll need to use. The value that's coming back from parentField.getValue()
is basically a numeric ID in string form.
import com.atlassian.jira.component.ComponentAccessor import com.onresolve.jira.groovy.user.FieldBehaviours import groovy.transform.BaseScript @BaseScript FieldBehaviours fieldBehaviours def childField = getFieldById("assignee") def parentField = getFieldById(getFieldChanged()) def selectedOption = parentField.getValue() def issueSecurityLevelManager = ComponentAccessor.getIssueSecurityLevelManager() def level = issueSecurityLevelManager.getIssueSecurityLevelsByName("Autor, Bearbeiter & Beobachter") if (selectedOption && level) { if(selectedOption == level[0].id?.toString()) { childField.setRequired(true) } else { childField.setRequired(false) } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.