Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptRunner listener for fixVersions field update for Jira Cloud

Alex Kuterman
Contributor
July 30, 2019

I'm trying to create a listener script that will listen for fixVersions field update, and will copy its new value into a custom field.

Does anyone done such a script and can share it?

I am failing at the retrieval of the fixVersions value:

 

def fixVersionsChange = changelog?.items.find { it['field'] == 'fixVersions' }
logger.info("fixVersions value is: {}", fixVersionsChange)

 

Running the above, results with:

2019-07-30 16:38:14.514 INFO - fixVersions value is: null

 

The above script is working well on custom fields.

Any ideas?

2 answers

0 votes
luka montin April 30, 2020

Hi Did you ever get an answer to this ? I too am trying to capture the added or removed fixversion ( on an epic .. so that i can update all its epic linked children ) 

0 votes
Kristian Walker _Adaptavist_
Community Champion
July 31, 2019

Hi Alex,

Thank you for your question.

I have just tested your code and added in an extra log statement to log out the whole of the changelog paramater when updating a fix version.

I noticed that in the changelog that was returned the field was called Fix Version rather than fixVersions.

Could I please ask you to try to updating your code to find the field named Fix Version as after doing this I was able to get the value of the changelog for fix versions logged out.

If this response has answered your question can you please mark it as accepted so that other users can see it is correct when searching for similar answers.

Regards,

Kristian

Alex Kuterman
Contributor
August 7, 2019

Hi Kristian,

 

I changed the field as you suggested:

 

def DeliveryDateChange = changelog?.items.find { it['field'] == 'Fix Version' }

logger.info("fixVersions is: {}", DeliveryDateChange)

 

When I’m changing the fixVersions (Fix Version) from 2.1.1 to 2.2, I’m getting the following response:

2019-08-04 06:16:51.526 INFO - fixVersions is: {field=Fix Version, fieldtype=jira, fieldId=fixVersions, from=10036, fromString=2.1.1, to=null, toString=null}

 

It is not recognizing the toString value

Kristian Walker _Adaptavist_
Community Champion
August 7, 2019

Hi Alex,

I have just done a test and confirm that the toString value is only populated when a fix version already exists and a new version is added.

This is the way that the changelog returned by Atlassian works and ScriptRunner is just returning this data. 

The reason appears to be that the change log is only showing what value was removed from the field and you would need to then get the value of the fix version of the field after the update in order to see what the latest version of the field is.

Regards,

Kristian

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events