Trying to compare 2 fields with Misc Custom Fields plugin

Hi,

I'm just basically trying to make a comparison out of 2 customfields that are from the same type.

I'm using a Text Calculated CF from the MISC CF add-ons.

It looks like this:

<!-- @@Formula: issue.get("customfield_xxxxx") != issue.get("customfield_yyyyy") ? "Yes" : "No" -->

 I've been trying with many types from text to nFeed fields (which was my initial target) but it still remains stucked on the "Yes" value.

Thanks very much for helping me.

1 answer

1 accepted

The formula is written in BeanShell, which is almost the same as Java. Thus you want to use the "equals" method to compare values. But be careful to first test for null values. For example, if your custom fields are of type "text", you can tr the following:

<!-- @@Formula: 
if (issue.get("customfield_xxxxx")==null || issue.get("customfield_yyyyy")==null)
    return null;
return issue.get("customfield_xxxxx").equals(issue.get("customfield_yyyyy")) ? "No" : "Yes" -->

Also, please note that this might not work for some custom field types which return complex objects that might not implement the "equals" method correctly.

For information on the value type of standard custom field types, see https://innovalog.atlassian.net/wiki/display/KB/Using+issue.get%28%3Cfield_name%3E%29+in+scripts

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,811 views 11 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot