What trigger the calculated field calculation / how it can be integrated with automation plugins Edited

Hi,

We would like to have an automated "calculated priority" calculated using JIRA Misc Custom field at issue creation.

We want to use this calculated priority to be used to set some of the fields of the issues (for example the standard priority, target date,...) using an automation plugin.

To pipeline/order the processes, we would like to know

* what trigger the "calculated priority" calculation (issue created JIRA postfunction? Another postfunction?)

* if you know some tricks what can be used to pipeline the jobs (if the calculated customfield raise an event, or if this is possible to set a properties / field of the JIRA issue)

Thanks you,

2 answers

1 accepted

This widget could not be displayed.

Calculated custom fields created by JMCF are updated when the issue is reindexed, which happens when the issue is modified or transitioned. 

However, you will also get a newly calculated value when you access the field using a JMWE (JIRA Misc Workflow Extensions) post function. So you could use JMWE post-functions on your create transition to do the other changes required (using Groovy scripts as value or condition). You might just have to push the post-functions down the list of you get errors. 

To access the Calculated field from a Groovy script, use issue.get(field name). 

David

Alright, thanks for explanation,

"JMCF are updated when the issue is reindexed, which happens when the issue is modified or transitioned"

"So you could use JMWE post-functions on your create transition to do the other changes required"

 

We tried with JIRA Suite Utilities postfunction. It works in Workflow transition, but not for issue creation (even when this is the last postfunction = after reindexation.

Have you already tested if this work with JMWE at issue creation? (it seems to be the same functionnality, but maybe not the same implementation..)

Capture.PNG

Unfortunately, you are right. Recent versions of JIRA caches an invalid null value for all calculated fields during issue creation, instead of waiting for the field to be accessed to calculate its value. This actually has nothing to do with the index (which is only used for searches and the tabular search results view).

There are two possible workarounds:

  1. you use the same formula in the Set Field Value post-function's Groovy value or condition code as you use in your calculated field (instead of accessing the calculated field)
  2. you reload the issue in the Set Field Value post-function's Groovy value or condition code before accessing its calculated field:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue

Issue myIssue = ComponentAccessor.getIssueManager().getIssue(issue.id)

if (myIssue.get("my calculated field") == [...]

The second solution requires that the Set Field Value post-function be placed at the bottom of the list.

This widget could not be displayed.

See: https://community.atlassian.com/t5/JIRA-questions/Can-other-field-values-be-changed-when-the-calculation-occur/qaq-p/431990

 

First of all, calculation only occurs when a "view issue" screen is displayed - never during a transition. [...]

Then, calculation occurs during indexing - at which time you cannot modify an issue.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

510 views 3 18
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you