Post function to increase Date Picker field in one day.

Issue #375 resolved
Shai Dahan created an issue

Hello @fcarmario

I hope you are well and you are enjoying the summer.

I have a quick question: I have a Date Picker (date only) type of field in one of the create screen in a specific project. Now I have another field called "Late Shift After 18:00" (Checkbox type of field) with only one option "Yes" (not required) under the in the Date Picker field. I would like to have a post function which will increase the date in one day on condition that the tick box "Yes" us marked ,i.e. the value is not Empty.

For example if on the create screen you have selected the date 28/02/2016 and you have ticked the box "Yes" than in the created ticket the date should be 01/03/2016

Is this feasible?

Official response

  • Fidel Castro Armario repo owner

    Hi Shai, Thanks. I hope you are well too.

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

    • Target field: select the Date Picker you want to increase.
    • Formula:
    {nnnnn} + {DAY}
    
    • Conditional execution:
    {aaaaa} = "Yes"
    

    replacing nnnnn with field code for Date Picker field, and aaaaa with field code for Checkbox custom field.

    In case you want to increase Date Picker field in 1 day skipping weekends, use the following formula:

    addDaysSkippingWeekends({nnnnn}, 1, LOCAL)
    

Comments (8)

  1. Fidel Castro Armario repo owner

    Hi Shai, Thanks. I hope you are well too.

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

    • Target field: select the Date Picker you want to increase.
    • Formula:
    {nnnnn} + {DAY}
    
    • Conditional execution:
    {aaaaa} = "Yes"
    

    replacing nnnnn with field code for Date Picker field, and aaaaa with field code for Checkbox custom field.

    In case you want to increase Date Picker field in 1 day skipping weekends, use the following formula:

    addDaysSkippingWeekends({nnnnn}, 1, LOCAL)
    
  2. Shai Dahan Account Deactivated reporter

    How can I achieve this through the create screen as there is no condition on "Create" transition (only validator) Should I create another transition?

  3. Shai Dahan Account Deactivated reporter

    Great suff @fcarmario

    All works like a charm and you can close this request.

  4. Fidel Castro Armario repo owner

    Hi @shai_dahan,

    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. Shai Dahan Account Deactivated reporter

    Hello @fcarmario

    Thank you very much for the heads up.

    I will try this feature as soon as I can

  6. Log in to comment