Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,553,440
Community Members
 
Community Events
184
Community Groups

Scriptrunner Behaviour to edit a custom field IF the field has certain value during transition

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"
}
}
 

 

2 answers

0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 07, 2022

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")
}
}
0 votes
Andrea Pannitti
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 06, 2022

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events