I need to set the assignee to the component lead only if the previous assignee was the lead of the previous component. I've got a Behaviours plugin script to set the assignee to the component lead:
import com.atlassian.jira.ComponentManager
FormField formComponent = getFieldById(fieldChanged)
FormField formUserField = getFieldById("assignee")
if (formComponent.getValue() != null && formComponent.getValue() != "") {
List components = formComponent.getValue() as List
usera = components.first().lead
formUserField.setFormValue(usera)
}
The plugin seems to act when a field changes. Can it know the pervious value of a field?