Account specific calculated fields: One JavaScript pushing data into two new fields

Hi

I have a calculated field that using a JavaScript does a specific calculation and posts the result into a new field. Let’s assume that field is called myCalculation. That all works fine.|

What I want to do is to create a second new calculated field which used myCalculation within its JavaScript. The issue here is that I need to ensure that myCalculation runs first otherwise the second calculation won’t work as it depends on it.
I think that’s not guaranteed.

So I was thinking…. Can I create one JavaScript in one calculated field but pushes data into two separate fields. Hope this makes sense.

I asked coPilot and it thinks I can do this

Example mapping in advanced settings:

[jira.customfield_fiscal]
name = "Fiscal Quarter"
data_type = "string"
javascript_code = ...
json_fields = ["fyQuarter"]

[jira.customfield_compliance]
name = "Epic Compliance Flag"
data_type = "integer"
javascript_code = ...
json_fields = ["complianceFlag"]

and in the JavaScript
Some JavaScript code here…

return { fyQuarter: currentQuarter,

complianceFlag: complianceFlag};

Should that work???

many thanks in advance Ralph

Check the Creating Reports from Jira multi-line text custom field in eazyBI , perhaps you can apply the idea for your use case (JS calculated field populates other custom fields). Note: since I am not fully sure how the JS code is being executed, I usually place custom field that contains JS code as the last one (just to guarantee that the custom fields are initialized before the JS code is being executed).

Hi @ralph.warta,

I don’t recommend referencing a JavaScript calculated custom field in another JavaScript calculated custom field. The JavaScript code execution sequence is not guaranteed to be exactly the same as the sequence in which you define the fields in the eazyBI advanced settings.

Instead, perform the same JavaScript calculation from your myCalculationfield and adjust the result as necessary for the particular field you are defining.

Best,
Roberts // support@eazybi.com

1 Like