Count issues that have some properties

Issue #862 resolved
Antônio Duarte created an issue

I need to count the total of issues of type "Test Case" (in fact, this issue type is a sub-task) that are in state "A Realizar", and whose Parent's issue has an issue link to issue "XPTO-125". The info "XPTO-125" is currently a text custom field named "Controle" that belongs to the issue whose workflow I'm running right now.

So, I created a post-function exactly like this:

count (issuesFromJQL ("project = " + %{Project key} + " AND issuetype = 'Test Case' AND status = 'A Realizar' AND " + %{Controle} + " IN " + %{Parent's linked issue keys}))

But it doesn't work.

I guess this problem: when I use %{Controle} above, I understand that your expression evaluator is looking for this custom field in the issues of type 'Test Case', but this is not TRUE. In fact, as I said before, %{Controle} is a custom field that belongs to the issue whose workflow is running NOW, and this is NOT an issue of issuetype 'Test Case'.

Am I right in my thoughts? If so, how can I build such expression where I want to use some custom field that belongs to the current issue, and not to the "JQL-searched" issue?

Thanks in advance

Comments (5)

  1. Fidel Castro Armario repo owner

    Hi @acelsoddbr,

    You should use "Mathematical and date-time expression calculator" post-function with the following formula:

    count(filterByStatus(filterByIssueType(subtasks(linkedIssues("", issuesFromJQL("issuekey = " + %{nnnnn}))), "Test Case"), "A Realizar"))
    

    replacing nnnnn with field code for Controle custom field.

  2. Antônio Duarte reporter

    Hi, @fcarmario ,

    I just made quick tests, and the function seems to work fine. I will extend its usage to fulfill all my needs. Just two points, please:

    1) In fact, I must count the issues that are in more than one single state and not only in "A Realizar". So, please, explain me how the expression below should be written correctly (I'm only giving you the idea of what I need, but I know this is not the correct syntax):

    count(filterByStatus(filterByIssueType(subtasks(linkedIssues("", issuesFromJQL("issuekey = " + %{nnnnn}))), "Test Case"), "A Realizar" or "Executando" or "Finalizado OK" ))

    2) I've read your Confluence documentation on the several options of linkedIssues() function, but the text was no so clear for my understanding. Besides, I saw no example similar as you typed on your support (something where we add the workflow states as parameters of linkedIssues() function). Can I have a different explanation on this function?

    Thank you very much.

    Antonio.

  3. Fidel Castro Armario repo owner

    Hi @acelsoddbr,

    You should use the following expression:

    count(filterByStatus(filterByIssueType(subtasks(linkedIssues("", issuesFromJQL("issuekey = " + %{nnnnn}))), "Test Case"), "A Realizar, Executando, Finalizado OK"))
    

    When you write an empty string (i.e., "") at parameter for selecting issue link types, JWT will consider that you don't want to filter by any issue link type, and all the linked issues will be returned, regardless of the issue link type.

  4. Antônio Duarte reporter

    Hi, @fcarmario ,

    Thanks once more for your valuable support. This is exactly the solution that our client was looking for. I'll study your expression above with more detail to understand better all the concepts involved. I see that these functions of JWT are indeed a great tool to help us on building such complex relationships between issues! This issue can be closed with success status. Regards Antonio

  5. Log in to comment