Would like a way to get Structure formula calculations into "normal" Jira custom fields
Structure formulas are extremely useful. Now our users would like ways of using them in other places within Jira. This may be tough in some ways because they are specific to the structure they are part of, but even something simple like the ability to choose an menu option or call some API to commit formulas into an underlying custom field could be quite useful.
collecting requirements, see comments
-
James C commented
Is this feature available or still being considered?
-
Aggelos Paraskevopoulos commented
Hi Igor,
nice to hear from you too!
Yes we've played a bit with the Java API, we managed to get values from the configurable "progress" column in one case. Thanks for sharing the info about the formula columns, we'll experiment a bit and get back to support if further help is needed.
Best regards,
Aggelos -
Hi Aggelos, great to hear from you!
If you're familiar with Structure's Java API, you can use the usual StructureAttributeService to retrieve formula values. See here: https://wiki.almworks.com/x/5LDrAQ
Formula column uses attribute with ID "expr". The parameters are: "formula", which is a text formula, and "variables", which is an object (map), where keys are variable names and values are attribute specs for the mapped values.
You can see how an attribute spec looks like if you use your browser tools to see the network call to /values REST resource after you have added or reconfigured a formula column.
Note that the automatic assignment of well-known names to Jira fields happens on the client, so you'll need to do that in your code if calling APIs.
Hope this helps! Please feel free to open tickets at https://support.almworks.com if you need further help.
Kind regards,
Igor -
Aggelos Paraskevopoulos commented
Hi Igor,
this is definitely a feature we are looking forward to. Is this corresponding to the "Hierarchical Custom Field' that you published on Structure's roadmap?
Until you get this implemented, do you have any guidelines for us (impatient people) on how to use the private Java APIs to have something usable in the meantime?
Best regards,
Aggelos -
Matthew, thanks for the feedback! Happy to hear formulas proved useful to you. I'd vote for this request myself, as we also found that we want to see the formula value on an issue page and maybe in other add-ons.
And you're right, it's a bit tricky. According to current thought, there are several ways to implement that:
1. Have Structure provide a new custom field type, similar to Calculated Field by Script Runner. The configuration of such field would involve selecting a structure to run upon and editing the formula in the same way you do that on the Structure Board. This means one custom field only shows values from one structure.
2. Same as above, but support only "simple" attributes, which don't depend on the structure. No totals and such. Then we need to configure only the formula.
3. Have a new synchronizer, which is installed on a structure and runs periodically, writing a formula value onto a standard custom field. The benefit here is that one can use standard fields that are supported by all add-ons, but there's going to be some delay before value is written, plus using synchronizers is less efficient (they would still run and update values even if no one is looking).
Which option appeals more to you?
Additional notes:
* To make things even less easier, one issue may appear in multiple places in a structure. If the formula includes structure-driven values like totals, an issue may have different values in different places. What should we show on the issue page remains a question.
* The Java API for formulas will be eventually published. We withhold it right now because it's evolving as we're developing this feature further (yes there's going to be more power soon!)
* Option 3, the synchronizer, can be generalized to allow pushing any Structure attribute into a custom field. This could be used to, say, have sub-issues have the same value in a field as parent issue. Or write the values calculated by Structure.Gantt like start/finish dates into custom fields.
Kind regards,
Igor