Forums

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

URL field workflow validator based on checkbox

Alex Smith
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.
November 30, 2021

Hi, I'm trying to set up a validation in a workflow that requires the URL field [RCA] to be filled when closing a ticket, but only when the radio button field [RCA requested] has the value "Yes".

Can someone tell me what I'm doing wrong here? Instead of only requiring [RCA] under that condition the field is always required, even if it has a value. Alternately should I use the JWT logical validator?

Thanks!

import com.atlassian.jira.issue.customfields.option.Option

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObjectByName("RCA requested")

cfValues['RCA requested']?.value != 'Yes' || cfValues['RCA']

Screen Shot 2021-11-30 at 2.00.16 PM.png 

2 answers

1 accepted

2 votes
Answer accepted
Max Foerster - K15t
Community Champion
December 16, 2021

Hey @Alex Smith

I just wanted to get back to you to explain the identical implementation with Jira Workflow Toolbox's Logical Validator. The choice of the validator would be the right one. 😁 👍🏼

The expression is written just as quickly:

%{issue.cfAAAAA} = "Yes" IMPLIES %{issue.cfBBBBB} != null

With the checkbox checked and no URL, the query will return false. The validator returns true in any other case (both fields are empty or URL filled without the checkbox). Have fun enhancing your workflows! :)

Best, Max

Alex Smith
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.
December 20, 2021

Hi @Max Foerster - K15t thank you so much! That's perfect, as we do have JWT. I simply couldn't figure out the syntax

Like Max Foerster - K15t likes this
0 votes
Alex Koxaras -Relational-
Community Champion
November 30, 2021

Hi @Alex Smith 

I've used the following code to one of my project and it worked:

import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObjectsByName("NDA")

cfValues['NDA']?.value != 'Signed' || cfValues['NDA link']

Replace NDA with your single select field and the NDA link field with your RCA link. The condition worked when NDA was equal to "signed" (your "Yes), and I couldn't proceed to the next transition.

Alex Smith
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.
December 2, 2021

Interestingly that only partially worked, at it was only successful when I set the radio button field [RCA requested] as == instead of != (which makes little to no sense). But then it required the URL field [RCA] whether the field value was "Yes" or it was empty. Maybe I need to add a second value to [RCA requested] and make it required no matter what.

cfValues['NDA']?.value == 'RCA requested'
Alex Smith
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.
December 2, 2021

My apologies, [RCA requested] is a checkbox field instead of radio buttons. Any suggestions if that might be causing the issue? Ultimately the field can either have the value "Yes" or it can be empty, and I only want the URL field [RCA] required when the value filled in with the only option of "Yes". Thanks.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.17.1
TAGS
AUG Leaders

Atlassian Community Events