Hi Team,
I'm trying to put together a behaviour in scriptrunner where during transition (RFP to Implementing) user required to change a custom field IF this field has certain value (Unknown, Backlog, Test A), lam pretty new to coding, any idea is appreciated.
Field Name: Planned Version
Field type: Version Picker (multiple version)
Condition: ask to update field if the field has the value (Unknown, Backlog, Test A)
import com.atlassian.jira.component.ComponentAccessor
def sourceStatusId = jiraHelper.getStatusByName("RFP").iddef targetStatusId = jiraHelper.getStatusByName("IImplementing").id
def PlannedVersionField = = getFieldById("customfield_10000")
if (issue.status.id = "targetStatusId") {
if (getFieldById.value == "Unknown" || "Backlog" || "Test A") {
ASK user to update the field "Planned Version"
}
}
Here is how I would do it
def plannedVersionField = = getFieldById("customfield_10000")
plannedVersionField.clearError()
def goingToImplementing = destinationStepName == 'Implementing'
def comingFromRFM = underlyingIssue?.status.name == 'RFP
def valuesThatRequireChange = ['Unknown', 'Backlog', 'Test A']
if(comingFromRFM && goingToImplementing){
if(plannedVersionField.value in valuesThatRequireChange){
plannedVersionField.setError("Please update. ${valuesThatRequireChange.join(',')} are not allowed when movig from RFP to Implementing")
}
}
Hi,
to do this, you could add a Simple scripted validator on the transition with this Condition:
!["Unknown", "Backlog", "Test A"].contains(cfValues['Your Custom Field'])
and setting the Error Message with a message like the following:
Please, update the field: Planned Version
And selecting the Field: Planned Version.
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.