Calculate Due Date

Issue #290 resolved
Jonas Santos created an issue

I'm trying to create a rule that when a issue is created, the field "Due Date" is automatically filled with D+2 (two days from the current date).

Example: If I create a issue now (13/apr/2016), the Due Date field must be filled with 15/apr/2016.

So I edited the workflow and added a "Post Function" on the first create flow with the following rule: addDaysSkippingWeekends(%{00057}, 2, LOCAL)

It's not working.

Can you help me please?

Comments (9)

  1. Fidel Castro Armario repo owner

    Hi Jonas,

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

    addDaysSkippingWeekends({00057}, 2, LOCAL)
    

    The problem is that you are using %{00057}, which returns a string value representing current date and time, but you should use {00057}, which returns the numeric value for current date and time, i.e., the number of milliseconds elapsed since January 1, 1970, 00:00:00 GMT.

  2. ME

    Hi, Fidel,

    I want to use the above provided solution but with some more logic. I want to have 3 separate results based on a custom field.

    So for example; if "custom field = A" do this > "addDaysSkippingWeekends({00057}, 3, LOCAL)" or if "custom field = B" do this > "addDaysSkippingWeekends({00057}, 6, LOCAL)" or if "custom field = C" do this > "addDaysSkippingWeekends({00057}, 9, LOCAL)".

    How would I do it in one post function?

  3. Fidel Castro Armario repo owner

    Hi @mosheeh,

    You can use "Set a field as a function of other fields" post-function with the following configuration:

    Captura de pantalla 2017-03-03 a las 18.55.52.png

    In the example T1 is the field whose value can be A, B or C.

    Setting rules are:

    (A)addDaysSkippingWeekends({00057}, 3, LOCAL)
    (B)addDaysSkippingWeekends({00057}, 6, LOCAL)
    (C)addDaysSkippingWeekends({00057}, 9, LOCAL)
    
  4. Fidel Castro Armario repo owner

    Hi @mosheeh,

    Since version 2.2.39, JIRA Workflow Toolbox supports Custom Schedules, and you can do all you are doing now using addTimeSkippingWeekends () and subtractDatesSkippingWeekends () functions, and much much more.

    I recommend you to take a look at it. You will be able to do amazing things using it.

  5. Log in to comment