version release date groovy script error

Ramaiah Pendli November 27, 2023

Hello,

we have migrated Jira from 8.7 to Jira cloud and we have a below script for release date script field but this script is not working in Jira cloud, could you please some one help me with the code.

def versions = issue.getFixVersions()
if (versions.size() != 1) {
    return null
}
 
def version = versions.first()
 
if (!version.releaseDate) {
    return null
}
 
return new Date(version.releaseDate.time)
Thanks!

1 answer

1 vote
Bobby Bailey
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.
November 27, 2023

Hi @Ramaiah Pendli , 

The issue you are coming up against is that the function getFixVersions() is a Jira Java API function. In Cloud you do not have access to the Java API, and so need to used the REST API to get your details about an issue. 

In this case, looking at the Get Issue API call, it looks like the API documentation doesn't include the exact structure for the fix versions. So, instead, I will have to call the API manually in my browser for an issue I know has fix versions. So, for example. I will load up:

https://[YOUR_URL_HERE].atlassian.net/rest/api/3/issue/[YOUR_ISSUE_KEY_HERE]

And look for how the fix data is structured. So, doing this I can see that the Fix Versions are stored under fields, so to access these I would use:

issue.fields.fixVersions

Does this help?

Kind regards, 

Bobby

Ramaiah Pendli November 28, 2023

Hi Bobby,

Thanks for your quick answer.

It is working if I input the direct issue key.

can you help me to apply the same script field in jira cloud.

 

Thanks

Bobby Bailey
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.
November 28, 2023

Sure, could you just confirm the feature you are using? Is it Scripted Fields feature?

Ramaiah Pendli November 28, 2023

Yes @Bobby Bailey we are using a scripted field.

Bobby Bailey
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.
November 29, 2023

In that case you should be able to use the above line I mentioned. 

In your Scripted Field script, change:

 

def versions = issue.getFixVersions()

 

To:

 

def versions = issue.fields.fixVersions

 

And this should get the value. 

Kind regards, 

Bobby

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM Trial
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events