Copy parsed text to field not working with addDaysSkippingWeekends function

Issue #877 resolved
Aggelos Paraskevopoulos [Cententia] created an issue

We have the following post-function that sets a date picker custom field with the value calculated from the supplied expression.

The following text parsed in advanced mode will be copied to Desired Response Date: 
addDaysSkippingWeekends({Date and time of creation}, getMatchingValue(%{Priority}, ["Critical", "Major", "Moderate", "Minor", "Low"], [10, 19, 24, 32, 32]) ,LOCAL) 

The function does not seem to work and clears the field value instead of setting the calculated one.

The same expression when placed on a JWT calculated date field works fine.

Any ideas?

Comments (7)

  1. Aggelos Paraskevopoulos [Cententia] reporter

    You are right. It works.

    Maybe it should be more clear in the documentantion or even prevent selecting as target one of those underlying field types?

    Thanks, Aggelos

  2. Fidel Castro Armario repo owner

    Hi @aggelosp,

    "Copy a parsed text to a field" post-function is intended to be able to set any field type, but the expression to be used for setting the field should always be a string expression.

    I think It's useful to have the capability of setting any kind of field with this post-function. When setting a date-time field, it's expected to receive a string representation of a date, like 2017-11-06. In your example, you could have used the following expression:

    dateTimeToString(addDaysSkippingWeekends({00057}, getMatchingValue(%{00017}, ["Critical", "Major", "Moderate", "Minor", "Low"], [10, 19, 24, 32, 32]) ,LOCAL) , LOCAL, SERVER_LANG)
    

    Anyway, it's always better to use "Mathematical and date-time expression calculator" post-function since this way we avoid unnecessary transformation to string, which also may cause a potential lose of precision.

    Anyway, we will try to improve the documentation to make it clearer. Thanks for the suggestion.

  3. Fidel Castro Armario repo owner

    Hi @aggelosp,

    You can also implement the same calculation using custom schedules but with support for holidays* using a schedule definition like:

    MON-FRI { 00:00 - 00:00; }
    
    # Annual Holidays
    JAN/1, MAY/1, NOV/1, DEC/25 {;}
    
    # 2017 Holidays
    2017/JAN/12, 2017/APR/13, 2017/APR/14, 2017/NOV/23 {;}
    

    with a formula like:

    addTime({00057}, getMatchingValue(%{00017}, ["Critical", "Major", "Moderate", "Minor", "Low"], [10, 19, 24, 32, 32]) * {DAY}, "my_schedule", LOCAL)
    
  4. Aggelos Paraskevopoulos [Cententia] reporter

    Hi @fcarmario ,

    Thanks for this. One of my colleagues is already experimenting with the new schedule feature on a recent client request and reported that it works like a charm :) So probably I'll adapt my expression too.

    Cheers/A.

  5. Log in to comment