How to get checklist values and use the IN equivalent of SQL commands

Marc Jason Mutuc
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.
January 14, 2015

I'm trying to figure out how to check if Check List Field has a specific value ticked.

Say Check List Field = CHECK1

Opions are OPT1, OPT2, OPT3.

I want to check if OPT2 is ticked and return a value. Thank you!

2 answers

1 accepted

0 votes
Answer accepted
David _old account_
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.
January 15, 2015
if (issue.get("customfield_12345") == null)
	return null;
if ("OPT2".equalsIgnoreCase(issue.get("customfield_12345").getValue())
  return "OPT2 checked";

where 12345 is the numerical id of the CHECK1 field (see the doc for an explanation of how to find it).

Marc Jason Mutuc
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.
January 17, 2015

Thank you David! Appreciate your answers. What if I duplicate named options? How to I distinguish between them? Is there also a syntax for it like below: cfValues['Custom Field Name'][0].getValue() == 'OK' cfValues['Custom Field Name'][1].getValue() == 'OK' cfValues['Custom Field Name'][2].getValue() == 'OK' cfValues['Custom Field Name'][3].getValue() == 'OK' cfValues['Custom Field Name'][4].getValue() == 'OK' cfValues['Custom Field Name'][5].getValue() == 'OK'

Marc Jason Mutuc
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.
January 17, 2015

also, I got the following error on the logs (I just checked now since I was confident is was going to work, sorry.): [innovalog.jmcf.fields.CalculatedTextField] CalculatedTextField: error evaluating formula: Sourced file: inline evaluation of: `` if (issue.get("customfield_13811") == null) return null; if ("Received". . . . '' : Error in method invocation: Method getValue() not found in class'java.util.ArrayList'

0 votes
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 17, 2015

I didn't get that your field was a multi select field. In that case, issue.get(...) will return an array list of Option objects. So you'll need to iterate over that array : for (Option o : issue.get(...)) {

if (o.getValue().equals("...")) return "...";

}

Marc Jason Mutuc
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.
January 20, 2015

Tried the following which is the first item in the checklist : <!-- @@Formula: if (issue.get("customfield_13811") == null) return null; for (Option o : issue.get("customfield_13811")){ if (o.getValue().equalsIgnoreCase("Received")) return "OK"; } --> Got the following error in the logs [innovalog.jmcf.fields.CalculatedTextField] CalculatedTextField: error evaluating formula: Sourced file: inline evaluation of: `` if (issue.get("customfield_13811") == null) return null; for (Option o . . . '' : Class: Option not found in namespace How do you detemine the letter o?

David _old account_
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.
January 20, 2015

Can you try by simply removing "Option" (keep "o : ")?

Marc Jason Mutuc
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.
January 22, 2015

Still not working. :(

Marc Jason Mutuc
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.
January 22, 2015

By the way, the field is a checklist. Although, I think that's the same with multiselect.

David _old account_
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.
January 22, 2015

"Not working" doesn't really help... Any error in the logs (if so, it has to be a different error)?

Suggest an answer

Log in or Sign up to answer