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

JQL JIRA query for custom field being equal to two other custom field values

I want to query my project for all issues where 

customField1 != value(customField2) + value(customField3)

Is it possible to do this in a JQL query?

I tried "cf[123]!=cf[456]+cf[789]", but that didn't work.

3 answers

1 accepted

1 vote
Answer accepted
Udo Brand
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.
Feb 15, 2016

Scriptrunner has a scripted JQL function which could help as long as your custom fields are date, datetime or numeric fields.

see here: https://scriptrunner.adaptavist.com/latest/jira/jql-functions.html#_expression

 

This is cool, but I really think another library is overkill for this. All I want to do is a pure JQL jquery that checks for one field being equal to the sum of two others. Surely there's a way to do this in pure JQL.

Udo Brand
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.
Feb 16, 2016

The JQL functions provided by Scriptrunner plugin can just do this. Your attempt will never work since you can't compare two (or more) fields in out of the box JQL.

1 vote
Vasiliy Zverev
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.
Feb 14, 2016

You can try using Script Field provided ScriptRunner plugin. Here is code example to get diffenrence between two date custom fields:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField

import java.sql.Timestamp

/**
 * Get number of days between to customfields
 */

CustomField startDate = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Дата выдачи согласованного MD.050");
CustomField endDate = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Дата выдачи в тестирование.План");

if ((startDate == null) && (endDate == null))
    return ""

long startDateInMls = ((Timestamp) startDate.getValue(issue)).getTime();
long endDateInMls = ((Timestamp) endDate.getValue(issue)).getTime();


if ((startDateInMls == 0) && (endDateInMls == 0))
    return ""

return "" + ( startDateInMls - endDateInMls)/(1000*60*60*24)

This plugin is avalable only for server version.

Hm I really need a pure JQL query to do it, because I'm just using a node.js app to run this. It should be very lightweight, and this is really the only thing it does, so there should be a way to do this just in JQL

1 vote
Stephen Deutsch
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.
Feb 14, 2016

Are you trying to say that customfield1 should be not equal to neither customfield2 nor customfield3?

In that case it would be like this: cf[123]!=cf[456] AND cf[123]!=cf[789]

If you are trying to actually add the fields together, that would be a different query.

I'm trying the latter, unfortunately. I'm looking for cf[123] where cf[123] is not equal to the sum of two other custom field values.

@Stephen Deutschcan you let me know is the above query JQL of it needs different plugin to execute?

Also Can you share any reference link around the same

Suggest an answer

Log in or Sign up to answer