Condition on Copy Parsed Text to Field

Issue #943 resolved
Nadine created an issue

Hello Fidel

Sorry, I haven't yet had the time to check my other open issue since I a more urgent one came up:

I have the following hierarchy of issue types (from top to bottom): 1. Project (1:n) 2. Sub-Project (1:n) 3. Phase 1:1 4. Forecast (Sub-task)

Since I am using Jira's workflow status to reflect an issue's lifecycle status, I have set up a single text line custom field (Forecast Status) to show the corresponding forecast status .

When a new forecast is created, the Forecast Status on that issue is set to "MM/YY Required". The same status is set on the parent (Phase)-issue and the Sub-Project and Project issues on top of that. When someone starts working on a forecast, its (and its Parent's) Forecast Status is set to "MM/YY In Progress". When the forecast is submitted, its (and its Parent's) Forecast Status is set to "MM/YY Submitted". So far, everything works.

Now I want the Sub-Project's Forecast Status to change to (1) "MM/YY In Progress" when the first of n linked Phases changes to "MM/YY In Progress" and (2) "MM/YY Submitted" when all of n linked Phases changes to "MM/YY Submitted".

So, I set up the following two PF on the Sub-Project's workflow: Copy a parsed text to a field (1) The following text parsed in advanced mode will be copied to Forecast Status:

replaceAll(%{Forecast Status}, "Required", "In Progress") 

Post-function will only be executed if the following boolean expression is satisfied:

(count(filterByPredicate(linkedIssues("has Phase"), %{Forecast Status} ~ "In Progress")) > 0) AND (count(linkedIssues("has Phase")) != count(filterByPredicate(linkedIssues("has Phase"), %{Forecast Status} ~ "Submitted")))

(2) The following text parsed in advanced mode will be copied to Forecast Status:

%{Forecast Status} ~ "In Progress" ? (replaceAll(%{Forecast Status}, "In Progress", "Submitted")) : (replaceAll(%{Forecast Status}, "Required", "Submitted"))

Post-function will only be executed if the following boolean expression is satisfied:

count(linkedIssues("has Phase")) = count(filterByPredicate(linkedIssues("has Phase"), %{Forecast Status} ~ "Submitted")) 

Unfortunately, I cannot get this to work.

Do you have any ideas on how I can get this to work?

Many thanks

Nadine

Comments (5)

  1. Fidel Castro Armario repo owner

    Hi @naschuett,

    I give you the solution for both requirements:

    REQUIREMENT 1:

    You should use "Write field on linked issues or subtasks" post-function in transition to "In Progress" in Phases's workflow with the following configuration:

    Captura de pantalla 2017-12-29 a las 10.44.57.png

    The rest of configuration parameters should remain empty.

    Source expression is:

    replaceAll(^%{nnnnn}, "Required", "In Progress")
    

    replacing nnnnn with field code for "Forecast Status" custom field.

    REQUIREMENT 2:

    You should use "Write field on linked issues or subtasks" post-function in transition to "Submitted" in Phases's workflow with the following configuration:

    Captura de pantalla 2017-12-29 a las 10.58.48.png Captura de pantalla 2017-12-29 a las 10.58.57.png

    The rest of configuration parameters should remain empty.

    Source expression is:

    replaceAll(^%{nnnnn}, "Required|In Progress", "Submitted")
    

    replacing nnnnn with field code for "Forecast Status" custom field.

    Boolean expression at parameter "Conditional execution" is:

    count(linkedIssues("has Phase", linkedIssues("is Phase of"))) - 1 = count(filterByStatus(linkedIssues("has Phase", linkedIssues("is Phase of")), "Submitted")) 
    
  2. Nadine Account Deactivated reporter

    Hello @fcarmario

    First of all, thanks for the prompt response.

    I have been testing your suggestions and they seem to work fine except for the condition on requirement 2: The syntax checker says it is correct but I guess the expression cannot work since it checks for the status which does not actually change to Submitted on the Phase workflow. It is rather the Forecast Status CF which changes to "MM/YY Submitted". Hence, I further guess it must be something like:

    count(linkedIssues("has Phase", linkedIssues("is Phase of"))) - 1 = count(filterByPredicate(linkedIssues("has Phase", linkedIssues("is Phase of")), %{Forecast Status} ~ "Submitted"))
    

    But that does not work either.

    Arghh, I feel like it is close but not quite right. Hope you can help (not now though, it's nearly New Year so I hope you take a well deserved break ;-))

  3. Fidel Castro Armario repo owner

    Hi @naschuett,

    First of all, happy new year.

    You have to add ^ before field code for "Forecast Status", since otherwise you are referencing the value of the field in current issue, instead of linked issues as you actually need.

    Use the following expression:

    count(linkedIssues("has Phase", linkedIssues("is Phase of"))) - 1 = count(filterByPredicate(linkedIssues("has Phase", linkedIssues("is Phase of")), ^%{nnnnn} ~ "Submitted"))
    

    replacing nnnnn with field code for "Forecast Status" custom field.

  4. Nadine Account Deactivated reporter

    Hello @fcarmario

    Happy New Year to you as well.

    Thanks for the advice.

    It finally worked when I deleted -1 from the equation:

    count(linkedIssues("has Phase", linkedIssues("is Phase of"))) = count(filterByPredicate(linkedIssues("has Phase", linkedIssues("is Phase of")), ^%{nnnnn} ~ "Submitted"))
    

    Seems logical to me now since I only want the Submitted Forecast Status set when all linked sub-issues have changed to Submitted.

    Guess you will hear again from me soon since I use your brilliant app excessively. ;-)

  5. Log in to comment