Validation on other issues numeric value

Issue #466 resolved
Itamar Ben-Sinai created an issue

Hi, How can I create the following validation?

"Deployment task" issue type has a numerical value in CF "Deployment order" (1-10) validation should verify that there are no other deployment tasks that are not closed and have a smaller value than the value in the issue in transition before allowing the issue in question to transit to next status.

Comments (11)

  1. Fidel Castro Armario repo owner

    Hi Itamar,

    I imagine that the Deployment tasks you want to check up are somehow related. Do they share a same Epic? Or are they linked to a common issue with certain issue link type? Or are they subtasks of a same parent? Please, tell me the type of relationship they share.

  2. Itamar Ben-Sinai reporter

    Hi, Currently, the only shared property is the project the issues belong to. May have other relation that can be filtered by, but not at the moment.

    Thanks

  3. Fidel Castro Armario repo owner

    You should use Validation based on JQL query with the following configuration:

    Captura de pantalla 2016-12-14 a las 12.23.23.png

    JQL Query is:

    project = %{00018} AND status not in ("Closed") AND "Deployment order" < %{nnnnn} 
    

    replacing nnnnn with field code for Deployment order.

    Note that %{00018} is field code for Project key.

    I have assumed that closed issues are those in "Closed" status. You can add more statuses to the list. For example: status not in ("Closed", "Resolved", "Done")

    Boolean expression is:

    {00058} = 0 
    

    Note that {00058} is field code for Ephemeral number 1, which contains the number of issues returned by the JQL query.

  4. Itamar Ben-Sinai reporter

    HI, Tested it , but it does not work as expetcted

    Validator:

    Only if the number of issues returned by the following JQL query project = Subscription and status not in Done and "Deployment order" < %{Deployment order} (stored in "Ephemeral number 1") satisfies the following boolean expression {Ephemeral number 1} = 0. Message to show when validation fails: "Blocking Deployment tasks are not done yet".
    This feature will be run as user in field Current user.

    Created 2 issues with Deployment order number (2 and 5)

    Expected results:

    • issue with Deployment order value of 2 can be transitioned (no other issues with lower number)
    • issue with Deployment order value of 5 cannot be transitioned, as long as the issue with Deployment order value of 2 is not Done

    Actual results:

    • Both issues were able to be transition
  5. Fidel Castro Armario repo owner

    You shouldn't have removed the parentheses from your JQL query, they belong to the syntax of lists in JQL queries.

    Use the following JQL query:

    project = Subscription and status not in (Done) and "Deployment order" < %{nnnnn}
    

    replacing nnnnn with field code for Deployment order.

    The original JQL query I provided you should also work.

  6. Itamar Ben-Sinai reporter

    This worked, Thanks!! When I tried to change the project name to %{00018}, it gave me an error, so I reverted to the original use of project name.

    the error

    ERROR IN BOOLEAN EXPRESSION "count(filterByPredicate(issuesFromJQL("project = %{00018} and status not in (Done)"), toNumber(^%{10219}) < toNumber(%{10219}))) = 0" : INVALID JQL QUERY IN "VALIDATION ON JQL QUERY": "project = %{00018} and status not in (Done)" : com.atlassian.jira.jql.parser.antlr.RuntimeRecognitionException: MismatchedSetException(37!=null)

  7. Fidel Castro Armario repo owner

    To do it you should use the following boolean expression:

    count(filterByPredicate(issuesFromJQL("project = " + %{00018} + " and status not in (Done)"), toNumber(^%{nnnnn}) < toNumber(%{nnnnn}))) = 0
    
  8. Log in to comment