Count of epics by summary text (Javascript calculated custom field)

I’m trying to extend the solution proposed in https://community.eazybi.com/t/filter-open-issue-by-summary/6046 to create a calculated custom field to show how many times epics have been split.

When an epic moves from one planning increment to another it is split into two. An epic with the summary: “my big epic” becomes “my big epic (Split Part 1)” and “my big epic (Split Part 2)”. It is possible that if an epic moves to a third planning increment it could branch into a third epic “my big epic (Split Part 3)” and so on

I can use

javascript_code = '''
var result;
if (issue.fields.summary && issue.fields.summary.match(/.*Split Part.*/)) { result = true;} 
else {
  result = false;
}
issue.fields.customfield_split_epic = result;
'''

to capture the epics that have been split but I’d like to capture the split number …1, 2, or 3 etc

I’ve tried

javascript_code = '''
var result;
var split;
result = "";
split = issue.fields.summary && issue.fields.summary.match((?<=Split Part ).) 
 switch(split) {
 		case "1":
 			result = "Split to future qtr";
 			break;
     case "2":
 			result = "Split from previous qtr";
 			break;
 		case "3":
 			result = "Split from previous qtr x 2";
 			break;

 	issue.fields.customfield_JA_split_epic = result
  }
'''
but my syntax is a bit off, obviously

Thanks

Paul

Hi @Paul44
Thanks for posting your question!

I suggest deleting the code (both codes) from eazyBI advanced settings and instead defining a new custom field in the import options with the code below (follow instructions here to learn about creating new calculated fields in the Import Options - New calculated fields

{
var splitfield = "No Split";
if (issue.fields.summary && issue.fields.summary.match(/.*Split Part 1.*/))
{
var splitfield = "Split to future qtr";}
  if (issue.fields.summary && issue.fields.summary.match(/.*Split Part 2.*/))
{
var splitfield = "Split from previous qtr";}
 if (issue.fields.summary && issue.fields.summary.match(/.*Split Part 3.*/))
   {splitfield = "Split from previous qtr x 2"};
return splitfield
}

Here is a screenshot of how the setup should look:


Best wishes,

Elita from support@eazybi.com

Much better. Works perfectly. Many thanks

1 Like