Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to use a Radio Button to validate a transition

Karl Samson
Contributor
July 25, 2024

I'm trying to setup a 'Simple Scripted Validator' using ScriptRunner. That allows the transition, if the Radio button in question has 'No' selected.

 

 

"import com.atlassian.jira.component.ComponentAccessor

// Get the custom field manager
def CustomFieldManager = ComponentAccessor.getCustomFieldManager()

// Get the custom field by name
def approvalField = customFieldManager.getCustomFieldObjectsByName("Verification?")

// Get the value of the custom field for the current issue
def approvalValue = issue.getCustomFieldValue(approvalField as String)

// Check if the custom field value is not "Yes"
return approvalValue != "Yes"

    return true"
The Script Editor likes the code, but the transition is blocked, whether 'Yes' or 'No' is selected!? 
Can anybody show me where my code is wrong please?
Thanks.

1 answer

0 votes
Jim Knepley - ReleaseTEAM
Atlassian Partner
July 25, 2024

I think that getCustomFieldObjectsByName returns a collection of CustomField objects and you're looking at that collection as though it's a discreet "yes/no" value.

Try something simpler:

def approvalValue = issue.getCustomFieldValue("Verification?")

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.12.8
TAGS
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!

Start here
AUG Leaders

Atlassian Community Events