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,559,417
Community Members
 
Community Events
184
Community Groups

Condition to see if a specific checkbox option was checked or not using smart-values

Nathan Gasseau
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Apr 20, 2023

Hey,

I have a custom checkbox field with multiple options and I want to see if one specific checkbox was checked or not.

Right now I am using the indexOf() function to see if the value is in the smart-value list, which works, it returns -1 if it's not checked and a different number if it is checked, but my condition using the .eq() function does not work and I am not sure why.

{{#if(issue."My custom checkbox field".value.indexOf("Option 1").eq(-1))}}

Option 1 was NOT checked

{{/}}

Can anyone tell me if they have a workaround to do this or why my condition won't work?

Thanks

1 answer

0 votes
Stephen Wrathall
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Apr 27, 2023

Hi @Nathan Gasseau,

Since your checkboxfield can have multiple values, then 'issue."My custom checkbox field".value' doesn't return a single value. It returns a list of values. See documentation of smart values lists here:

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/

https://confluence.atlassian.com/automation/examples-of-using-smart-values-with-lists-993924631.html

I tested your scenario out, with slightly different values, and found that you should be able to do this:

{{#if(issue."MyCustomCheckboxesField".value.first.indexOf("Checkbox3").eq(0))}}
Checkbox3 was checked
{{/}}

As you can see, I'm using "first". So if they picked it second, then this wouldn't pick it up. Unfortunately there is no "contains" function I'm aware of for SV lists, although you could work around it by using multiple checks with ".get(0)", ".get(1)", etc.

Working

Four Log actions

Value: {{issue."MyCustomCheckboxesField".value}}
IndexOf: {{issue."MyCustomCheckboxesField".value.indexOf("Checkbox3")}}
V1: {{#if(issue."MyCustomCheckboxesField".value.indexOf("Checkbox3").eq(-1))}} Checkbox3 was NOT checked {{/}}
V2: {{#if(issue."MyCustomCheckboxesField".value.first.indexOf("Checkbox3").eq(0))}} Checkbox3 was checked {{/}}

Four outputs

Log action
Value: Checkbox3, Checkbox4

Log action
IndexOf: 0, -1

Log action
V1:

Log action
V2: Checkbox3 was checked
Nathan Gasseau
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 02, 2023

@Stephen Wrathall Thanks for your answer it was very helpful.

This is ok if I have a small checklist with less than 3 options, but it gets complicated if the checkbox list has more options.

Are you aware if anyone is working on a .contain function of some sort because I feel like this is a pretty basic need when working with lists.

Wojciech Wardaszko _HeroCoders_
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 03, 2023

Hi @Nathan Gasseau

Welcome to the Community!

If I understand your usecase correctly, I think you could use our App Issue Checklist Free or Pro to create and operate the checklist and then use the {{fieldChange.fromString.match("(?m)(^\* \[] Checkbox 1$)")}} and {{fieldChange.toString.match("(?m)(^\* \[x] Checkbox 1$)")}} smart values/  function to search the Checklist Text custom field to see if the change to the field did affect the checklist item in question. 

This is much easier to duplicate than the solution proposed by @Stephen Wrathall (great learning opportunity by the way, thanks!) but it requires the use of our third-party app.

For this to work you'd need to enable the Save Checklist data to Jira custom fields option in our app's global settings, so the Checklist Text field actually does get synced with the checklist in the UI.

If you need more guidance on how to make this work, feel free to ask here or reach out to our team via our service portal.

Cheers!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events