Issue with validation

Issue #178 resolved
Adolfo Casari created an issue

Hi Fidel,

I want to validate that when creating an issue, its DueDate isn't later than the duedate of a given issue in the project. Based on this:

https://bitbucket.org/fcarmario/jira-workflow-toolbox/wiki/amazing/Preventing%20Issue%20Creation%20If%20Already%20Exists%20Another%20Issue%20With%20Same%20Field%20Value

I followed both approaches, but it won't let me create the issue when its duedate is less than the duedate of the given issue (it should).

These are the validations in transition Create Issue:

count(filterByIssueType(getIssuesFromProjects(%{00018}), "TareaProyecto"))= 0 OR count(filterByFieldValue(filterByIssueType(getIssuesFromProjects(%{00018}), "TareaProyecto"), {00012},<, {00012})) = 0

alternatively,

project = "%{00018}" AND issuetype="TareaProyecto" AND duedate < "%{00012}" {00058}=0

TareaProyecto is a "singleton" in the project. It represents the project, so the idea is that when I create other issue types in that project they can't have a duedate later that that of that issue. Example:

DD TareaProyecto = 13/10/2015 DD any other issue in that project shouldn't be 14/10/2015 or later, only 13/10/2015 or earlier.

Comments (20)

  1. Fidel Castro Armario repo owner

    I have tried both solutions, and both are working perfectly for me. I have used JIRA 7.0 and Jira Workflow Toolbox 2.2.

  2. Fidel Castro Armario repo owner

    Let's do some debugging. Please, do the following temporary changes to "Create issue" transition in order to create a debug comment:

    1) Remove the validator, or inhibit it adding a term like "true OR".

    2) Add a "Copy a parsed text to a field" post-function with the following configuration:

    • Target field: New comment
    • Parsing mode: Advanced
    • Text to be parsed:
    "Issues TareaProyecto: " + toString(filterByIssueType(getIssuesFromProjects(%{00018}), "TareaProyecto")) + "\n\n" + "Issues TareaProyecto filtered by Due Date: " + toString(filterByFieldValue(filterByIssueType(getIssuesFromProjects(%{00018}), "TareaProyecto"), {00012},<, {00012}))
    

    Please, let me know which comment is generated.

  3. Adolfo Casari reporter

    This is what I get in the comment:

    Issues TareaProyecto: TDAI-22

    Issues TareaProyecto filtered by Due Date: TDAI-22

  4. Adolfo Casari reporter

    I created 2 issues, one with the duedate earlier and the other later, in both cases I got the same comment as above.

    I think that in the first case it should be empty and in the second have TDAI-22

  5. Adolfo Casari reporter

    Fidel, the problem is the DueDate that is reading from TareaProyecto. I add the postfunction attached to print both. The current issue is OK (12/10/2015 as entered in the screen), but the one from issue TareaProyecto is wrong (it's 13/10/2015, not 09/10/2015).

    This is what I get in the comment:

    Issues TareaProyecto: TDAI-22

    Issues TareaProyecto filtered by Due Date: TDAI-22

    Current Issue Due Date:1.4446188E12

    2015-10-12

    TareaProyecto Due Date:1.4443596E12

    09/10/2015

  6. Adolfo Casari reporter

    I found the problem: the duedate read from TareaProyecto was not the last one, but the previous one. The issue view was showing 13/10/2015 as duedate but the issue navigator had 09/10/2015, the previous value for the duedate. After reindexing, all is OK. Any ideas how this can happen? I am using a postfunction to set the duedate in TareProyecto and then there is a reindex function. I have attached it here.

  7. Fidel Castro Armario repo owner

    Adolfo,

    You found a bug: the plugin is not reindexing parent issue when a post-function has updated a field on parent issue.

    I have made available the following versions fixing the problem:

    Please, confirm that these versions solve your problem.

    Thanks.

  8. Adolfo Casari reporter

    Thanks. I will install 2.1.37_beta_1 later today. Just a question about the plugin versioning.In marketplace:

    2.2 : JIRA Server 6.2.3 - 7.0.0 2.1.36 : JIRA Server 5.0 - 6.4.12

    I see an overlap of versions (6.2.3 - 6.4.12) ??

  9. Fidel Castro Armario repo owner

    Versions 2.1.x higher than 2.1.36 will not carry new features. The intention is to only release a version occasionally for fixing bugs.

    All the new features will be implemented in versions 2.2.x.

    In reality version 2.1.37_beta_1 is compatible up to JIRA 6.4.12, but it won't make sense to install it in JIRA 6.2.3 and higher, since you will be missing new features carried by JWT 2.2.

  10. Fidel Castro Armario repo owner

    Yes. It's technically very costly to keep supporting a very high range of versions. For sometime, bugs will be fixed in versions compatible with JIRA 5.0 to 6.2.2.

  11. Adolfo Casari reporter

    Thanks for the info, I will be upgrading this particular instance from 6.1.5 to 6.4.12 next week.

  12. Log in to comment