Cannot get Calculated Text Field to work

Khachik Badeyan June 22, 2018

I am trying to create a custom field, to compare the values of my second unreleased version and the current issue's fix version, however when I try to create a custom field that returns the value of the second unreleased version, it works in Groovy Script Tester (JMWE), but not when I try to use it as a custom field (JMCF). Here is the script:

<!-- @@Formula:
issue.getAvailableOptions("versions").findAll{version -> ! version.released} .getAt(1).name -->

  

2 answers

1 accepted

1 vote
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 22, 2018

As other people already answered, JMCF 1.x indeed uses BeanShell, not Groovy. Also, the getAvailableOptions method is not available in JMCF 1.x.

JMCF 2.0 will change all this, but it's still a couple of months away.

In the meantime, try this:

<!-- @@Formula:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.project.version.Version;
import com.atlassian.jira.project.version.VersionManager;

VersionManager versionManager = ComponentAccessor.getVersionManager();
versions = versionManager.getVersionsUnreleased(issue.get("project").getId(), false);
if (versions.size() < 2)
return null;
return versions.get(1).name;

-->
Khachik Badeyan June 22, 2018

Thanks! Waiting for JMCF 2.0 then!

0 votes
Danyal Iqbal
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 22, 2018
Khachik Badeyan June 22, 2018

I wonder if it's possible to do the same with Jira Misc Custom Fields plugin.

Danyal Iqbal
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 22, 2018

I am not sure, I was always under the impression that it could only evaluate java expressions / @@Formuls with Beanshell syntax.

I would wait for someone with more experience to chime in.

Khachik Badeyan June 22, 2018

I researched further, and turns out yes.

JMCF is using Beanshell, however there isn't a big community for JMCF's Beanshell use. I hope someone here can help me with converting the script or telling me what I can expect from Beanshell and hat I shouldn't.

Danyal Iqbal
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 22, 2018

I would open a support ticket and hope that the folks at JMCF are nice enough to offer a resolution.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events