Not allow issue created for certain block dates?

Issue #863 new
Chau created an issue

Say I have a custom Date/Time picker "Deployment Date". Is there a way that we don't allow to user to create any issue when the "Deployment Date" falls into certain "predefine dates".

In the workflow, I'm thinking of having a validator for Create transition, something like %{11200} not in ["15/Aug/17", "16/Aug/17"]

There is a huge disadvantage is that we have to hardcode the list of dates in the workflow and if we need to add more dates, we have to modify this hardcoded list. Plus, users are not be able to view the list of lock date to be aware.

Is there another way?

Comments (10)

  1. Fidel Castro Armario repo owner

    Hi @chaunguyen2007,

    You can implement your requirements using project properties, which allow you to add new dates simply by editing project's description, and you will bee making it visible to your users, since project description is visible to everybody.

    This is the solution step by step:

    1) Create a project properties called deployment_forbidden at your project's description. Use the following syntax:

    project_property.png

    {deployment_forbidden=2017-08-15, 2017-08-16}
    

    IMPORTANT: Respect the date format in the example above.

    2) Use "Boolean validator with math, date-time or text-string terms" in you Create Issue transition with the following boolean expression:

    count(filterByPredicate(toStringList(projectProperty("deployment_forbidden"), ","), stringToDate(trim(^%), LOCAL) = datePart({00057}, LOCAL))) = 0
    
  2. Chau reporter

    Thanks for the response. Having the date as text in Project Description seems to be odd to users whenever they need to view the blocked dates. With the similar logic above, can you compare with the list of dates from a FILTER??? I'm thinking this: 1. Having a new Date Picker custom field which called "Blocked Date" 2. For each blocked date, create an associated issue (these issues can reside at another project). 3. Create a filter like "All Blocked Dates" which queries all these issues. 3. In "Boolean validator with math, date-time or text-string terms" in Create Issue transition perform the validation like: for each of the issue in "All Blocked Date" filter if Deployment Date = Block Date => fail validation. Is that possible???

  3. Fidel Castro Armario repo owner

    Hi @chaunguyen2007,

    Yes, you can also do it as you explain. In that case you should use the following validator:

    count(filterByPredicate(issuesFromJQL("project = PPP and issuetype = 'Blocker Issues'"), ^{nnnnn} = datePart({00057}, LOCAL))) = 0
    

    replacing PPP with the project key of the project where you enter the Blocker Issue, and nnnnn with field code of Blocked Date custom field.

  4. Chau reporter

    Thanks Fidel, I'll try your suggestion but is that possible to go one step further, comparing range? Instead of "Block Date" field, we should have 2 fields call" "Start Block Date" and "End Block Date". Then if the "Deployment Date" is falling into the range of "Start Block Date" and "End Block Date", it will fail the validator.

    By the way, in your logic, how come you don't use the filter name "All Blocked Dates"? Why it needs to compare with {00057}?

    Thx

  5. Fidel Castro Armario repo owner

    Hi @chaunguyen2007,

    You can use the following boolean expression instead:

    count(filterByPredicate(issuesFromJQL("project = PPP and issuetype = 'Blocker Issues'"), ^{sssss} <= datePart({00057}, LOCAL) AND datePart({00057}, LOCAL) <= ^{eeeee})) = 0
    

    replacing sssss with field code of Start Block Date, and eeeee with field code of End Block Date.

    In relation to your other question: I cannot reference a filter from a boolean expression, but I can use the JQL query associated with the filter. You can use the following boolean expression:

    count(issuesFromJQL("my_JQL_query")) = 0
    

    replacing my_JQL_query with the JQL query of your filter. I think that this solution is preferable to my previous suggestion, since this one is more efficient.

  6. Chau reporter

    Hi @fcarmario , I tried your last expression and it works because you only compare it with the "Current time", {00057}. count(filterByPredicate(issuesFromJQL("project = PPP and issuetype = 'Blocker Issues'"), ^{sssss} <= datePart({00057}, LOCAL) AND datePart({00057}, LOCAL) <= ^{eeeee})) = 0

    However, as the content of my question, it should compare with data time of another field, Deployment Date from another issue which is in the Deployment Issue Type. How can we proceed that?

    Also, in "Message to show when validation fails", how do we show the "Start Block Date" and "End Block Date" of the "Blocker Issues" to the users?

  7. Chau reporter

    Never mind, i found the example from your documentation by removing the reference "^" and it seems to works: count(filterByPredicate(issuesFromJQL("project = AP and issuetype = 'Date Blocker'"), ^{11422} <= {11200} AND {11200} <= ^{11423})) = 0

    However, I still need to have a way to display the value of "Start Block Date" and "End Block Date" as part of the message to users.

  8. Fidel Castro Armario repo owner

    You can insert the field codes of both Date Picker fields (i.e., %{11422} and %{11423}) in the custom failure message of the validator. This way you can inform the user with precission about the cause of why the validator is not being satisfied.

  9. Chau reporter

    I try that but it displays no value which make sense because those fields are empty. The Start Block Date and End Block Date are in the "Date Blocker" issue though. The current Deployment issue doesn't have the value for these field.

  10. Fidel Castro Armario repo owner

    Sorry, currently it's not possible to do it, but there is a modification in the roadmap that will make it possible. We will notify in this email when it is possible.

  11. Log in to comment