I have a custom multiple issue picker field shown in a transition screen. I want to validate this field before the transition is executed and prevent a value to be removed from it, in case a certain condition is not met.
I am already checking and doing further processing with the values which are added/removed from this multiple issue picker field in an Automation rule which runs when the field is changed but I cannot also validate and prevent the field change inside an Automation rule (because it happens AFTER the actual field change).
If I try to add my logic to a custom script in the workflow transition validator, I don't know how to access the "previous" value of this field, to be able to check whether the values which were removed are "compliant".
After several attempts, I was able to access it using:
import com.atlassian.jira.component.ComponentAccessor
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def changeItems = changeHistoryManager.getChangeItemsForField(issue, "Custom Field Name")
if (changeItems && changeItems.size() > 0) {
def previousValueOfField= changeItems.last().getToString()
}
Which add-on are you using for your transition validator?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Sam! Thanks for checking this.
I am using ScriptRunner for my custom script transition validator.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.