Adding new calculated field as Custom Import field

Hi,

I want to import LinkedIssues from Jira where the outward link = “is a key result for”

I want to add it to the Custom fields import tab, but only for my account.

I want to use the Advanced settings: New calculated field.

So at the bottom of all the Custom Fields I like to add that field as a Calculated Custom field.

I’ve selected Add new calculated field and in the popup I’ve populated the required fields.

I believe I have to add in the “Add additional advanced settings”-block:
name = “is a key result of”
outward_link = “is a key result of”
issue_type = “Epic”
dimension = true
multiple_values = true

But I don’t have a clue what I need to put in the “Custom JavaScript code” block.

Can someone help me. I’m not the admin of Jira or EazyBI so just want to create that custom field for my Account.

Hi Whaleshark,
Welcome to the eazyBI community!

In this case, the code for site advanced settings is more simple, but if you do not have admin access, you can create this field in Jira import options.

Here is how it would look:

You do not have to write anything in additional advanced settings because it is covered by name fields. The JavaScript part is:

var issuelinks = new Array();
//goes through all issue links
if (issue.fields.issuelinks) {
  var links = issue.fields.issuelinks;
  for (var i = 0; i < links.length; i++) {
    var link = links[i];
    //looks for outward links "is a key result of" to Epics
    if (link.outwardIssue) {
      if(link.outwardIssue.fields.issuetype.name && link.outwardIssue.fields.issuetype.name == 'Epic' && link.type.outward == 'is a key result of') {
        issuelinks.push(link.outwardIssue.key);  
      }
    }
  }
  return issuelinks.join(",");
}

A key difference is that a return statement is always required when defining custom fields in Jira import options.
And here you can also test the code with some sample issues before running the import.

Let me know if that works for you or if you have more questions.

Best,
Ilze

1 Like