How to create a new custom field based on another javascript custom field

Hello, @eazyBI-Staff

I need your help, please.

I calculate a javascript custom field that adds a text classifier (let’s call it “Classifier”) for all tasks at all levels of the hierarchy (Epics, Issues and Sub-tasks). Based on this classifier, I need to add a new field (lets call it “New data”) that can calculate the Time spent on this task multiplied by а factor associated with this classifier. Thus, I’ll have such data:

  1. Epic 1: “New Data” = Time Spent * 2 + “New Data” from all Tasks in it

1.1 Task 1: “New Data” = Time Spent * 3 + “New Data” from all Sub-tasks in it

1.1.2 Sub-task 1: "New Data" = Time Spent * 4 
  1. Epic 2

Could you, please, help me how can I write this correctly? Maybe I need to create a new calculated javascript custom field (right now the “Classifier” has 260 lines of code, and I really don’t want to copy those 260 lines into a new calculated javascript custom field just to multiply Time spent by the classifier’s factor)? Maybe I can use the previously calculated javascript custom field “Classifier” in calculating this new calculated javascript custom field or can I calculate both “Classifier” and “New Data” in one piece of code in javascript altogether? Or would it be easier to just create a new dimension?

P.S. I need it to work quickly

Roughly speaking, the javascript code might look like this:

if (issue.customfieldXXXXX = data1)
    "Classifier" = "Test1",
    "New Data" = issue.timespent * 10.8
elseif (issue.customfieldXXXXX = data2)
    "Classifier" = "Test2",
    "New Data" = issue.timespent * 9.2


When defining new Javascript fields, we do not recommend using one JS with a reference to another JS (in another field) as the sequence of the JS field calculation can not be predicted.
Instead, we would recommend moving all the scripts to one custom field definition (one JS) and then using just the outcome in the new field.
Then you could re-use the same formula to calculate the value for the new field.

You can reach out to for more details. Then provide your SEN and current scripts you tried so far.

Martins / eazyBI

@martins.vanags Hi, I solved this problem on my own

1 Like