what exactly is this code doing and how does it relate to status to being no plan, late, or at risk?

David Gibson March 24, 2022

This is for building the structure.

If (MATCH(issuetype, "Epic") ; If (MATCH(resolved,""); If (MATCH(JOIN#children{storystatus},"*NOPLAN*"); "{panel:bgColor=#ff5733}NEED PLAN{panel}"; MATCH(JOIN#children{storystatus},"*RED*"); "{panel:bgColor=#ff5733}LATE{panel}"; MATCH(JOIN#children{storystatus},"*YELLOW*") ; "{panel:bgColor=#ffc300}AT RISK{panel}"; "{panel:bgColor=#0cff00}ON PLAN{panel}"); "{panel:bgColor=#0cff00}COMPLETE{panel}" ) )

 

this is the Formula for variable story status

IF(issuetype != "Epic"; IF(!DEFINED(resolution); case( sprint; ""; "NOPLAN"; "/(?:,([^,]+)){2}/"; "RED"; "/(?:,([^,]+)){1}/"; "YELLOW"; "GREEN" ) ) )

1 answer

2 votes
Nicholas Ellis _ALM Works_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
August 18, 2022

Hi David,

Welcome to the community!

First I should mention it looks like this answer is tagged with Jira-cloud, but you are definitely on Server or datacenter.  On cloud you can't have one formula reference another.

Secondly, I've reformatted the code so it is easier to read but haven't changed it functionally.

If (MATCH(issuetype, "Epic") ; 
If (MATCH(resolved,""); 
If (MATCH(JOIN#children{storystatus},"*NOPLAN*"); "{panel:bgColor=#ff5733}NEED PLAN{panel}";
 
MATCH(JOIN#children{storystatus},"*RED*"); "{panel:bgColor=#ff5733}LATE{panel}";
 
MATCH(JOIN#children{storystatus},"*YELLOW*") ; "{panel:bgColor=#ffc300}AT RISK{panel}";
"{panel:bgColor=#0cff00}ON PLAN{panel}");
"{panel:bgColor=#0cff00}COMPLETE{panel}" ) )
 

Going line by line:

  1. checks if this row is an epic
  2. checks if the item has an empty resolution (i.e. it is not resolved)
  3. This is a bit complicated but essentially the second formula storystatus returns "NOPLAN", if the unresolved epic is not assigned to a sprint.  If this was at the initiative level we are checking that any epic directly underneath (what #children specifies) returns that string.
  4. if we don't find "NOPLAN", we check for "RED".  RED is returned by storystatus when the regex is matched. the regex is "/(?:,([^,]+)){2}/".  It looks like it is looking for at least 3 sections separated by 2 commas in the name of the sprint.  
  5. Yellow has a very similar regex, but we are looking for 1 comma in the sprint name, and we return YELLOW
  6. This line is the default return which gives us "ON PLAN", which is basically saying we didn't find RED, YELLOW, or NOPLAN in the underlying epics
  7. This line returns "COMPLETE" in a panel, and is only reached if the resolved match on line 2 returns false, but I would expect comparing any string to empty string would return true, so I'm not sure if this line ever executes.

Ultimately the Regular expressions are the hardest part to decode, but hopefully I've helped to point you in the right direction.  

I would expect there are much nicer ways to do what someone has tried to do here.  I'd start with our sample formulas documentation.

Cheers,
Nick

Suggest an answer

Log in or Sign up to answer