All eazyBI for Jira eazyBI for Confluence Private eazyBI

Global calculated fields (RENAMED)
eazyBI for Jira

This page describes advanced Jira and eazyBI integration. If you need help with this please contact eazyBI support.

If you would like to pre-calculate and import in eazyBI additional calculated custom fields then

  • you can either use some add-on in Jira to create some Jira calculated and scripted custom fields,
  • create a new calculated field specific to the particular eazyBI account with new calculated field,
  • or you can define calculated custom fields using JavaScript in eazyBI advanced settings as described further (and then they will be available just in eazyBI and not in Jira).

If you have larger number of Jira issues then it is better to import calculated custom fields and not to create calculated members with complex MDX formulas. Calculated custom fields are pre-calculated just once during Jira import and then saved in the eazyBI database and then eazyBI queries will perform much faster using pre-calculated data.

On this page:

Define global calculated field in eazyBI advanced settings.

You can define an additional custom field in the advanced settings. This field is shared with all eayBI accounts on your instance. However, the data admin should select and import it into the account before using it in the reports.

For each new field, describe the following settings:

  • Use your own customfield_name custom field name where name is some unique descriptive name of your additional calculated custom field. Best practices for naming the custom fields: keep it short and use just lowercase without underscores, special symbols, or camelCase.
  • Add a name setting and specify a display name for this calculated custom field that will be visible in Jira import custom fields selection (these calculated custom fields will be always visible for any Jira project selection).
  • Add javascript_code which will calculate and store in issue.fields.customfield_NAME result of the calculation. This JavaScript code can use the issue object in the same way as in the custom JavaScript code in Jira import options.

The order of the execution of JavaScripts for custom field calculations is not defined. We recommend avoiding reference from one JavaScript calculated custom field to another as it can give an unpredictable result. 

Here is an example of a calculated custom field "Issue summary". eazyBI imports issue key and summary as a name by default. The example code below will import the summary only as a property for an issue:

[jira.customfield_sumry]
name = "Summary"
data_type = "text"
javascript_code = '''
if (issue.fields.summary) {
  return issue.fields.summary;
}
'''

Validate the Javascript code

We highly recommend testing and debugging your JavaScript code before using it in data import. You can do this in Jira import options (from the main menu Source Data → Edit Jira import options → tab Additional options → Add custom JavaScript code). Paste your code in Custom JavaScript code and specify an issue key on which you would like to test your JavaScript code. Please note that in the field Custom javaScript code, you should paste only the javascript_code part (code between opening and closing quotation marks ''') without other parameters for advanced settings.

Test custom JavaScript code with several issues and validate if the newly defined custom field results appear as needed.

By default, you can see only standard-issue fields as well as selected custom fields in the issue JSON object. Additional issue fields comment and issuelinks will be returned only if  issue.fields.comment and issue.fields.issuelinks are used in the JavaScript code to access these fields.

See a short video on validation here:

Hi,

I would like to show you how to validate a Javascript code which you are planning to use in eazyBI advanced settings when defining a new calculated custom field.

Often calculated fields are a good way to calculate results for issues during data import

Such an approach can make your report significantly faster in some cases.

Let's look at the use-case where I want to show the first assignee for each issue in my report.

I have already a report with "Issue" dimension members at issue level in rows and property "Issue assignee" from the "Measures" dimension in columns that displays the current assignee.

In order to show the first assignee, there are multiple ways how to do that.

This time I will choose a Javascript calculated custom field.

With the help of this scripted field, each issue would get the first assignee during the data import when the field is defined in advanced settings.

I can build the Javascript code from scratch but I can also modify an existing script that eazyBI team has published on the documentation page or in one of the community posts. When building the Javascript code it is very important to validate the results before it is actually imported in eazyBI data cube.

Now, let's look at the Javascript code for the first assignee that can be found in one of the community posts if I search for the First assignee

(https://community.eazybi.com/t/first-user-assigned-to-issue/2181)

Before you use the Javascript for import it is better to validate the results on one sample issue in eazyBI import options page

To validate results, go to Source Data and click "Edit" to open import options.

Next, open tab "Additional options" and click to "Add custom Javascript code"

Now copy just the Javascript code from the custom field definition and paste it to test the code on a few sample issues.

Scroll down to see calculated results in the JSON view.

If you find the results correct for a few sample issues, you can assume the Javascript is built correctly,

Next, clear the "Custom Javascript code" area and close the import options page without saving it. Now open eazBI advanced settings and add the full custom field definition.

Make sure that the new custom field definition has the correct data type, name, and correct field ID path

After advanced settings are updated, it is safe to go to the "Source Data" tab and open eazyBI import options to select your new custom field for import and save the settings or directly import data in your data cube.

After the import is completed, check that the new field has correct values imported in the dimension.

Thanks for watching!

How to make changes in advanced settings

There might be a situation when you want to adjust or change the JavaScript calculated custom field in advanced settings, but the changes are not working as expected. Whenever changing advanced settings for custom fields, you might want to perform double data import to ensure the correct outcome of changes.

  1. In the import option, deselect the custom field from data import and import data. This action will clear the previous data and data structures (even if you see them as empty).
  2. Wait for the data import to complete.
  3. In the import option, select the custom field for data import and import data for the second time.