Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,293,657
Community Members
 
Community Events
165
Community Groups

How to pull out the last added value from the fixVersion field?

Edited

Hi,
We need to develop a sil script where the last added version in issue is needed. What are the ways to pull the last added value from the fixVersion field?

1 answer

0 votes

Hi Ellen.

There's nothing on the stored data that will tell when a version was added, so I don't know if there's a reliable way to tell which version was recently added.

Considering how DB works we may assume larger ID values are more recent (I wouldn't call that bulletproof, but it may work on most cases).

Then you may choose to work with admGetProjectVersions and admGetProjectVersion to get the version with the higher ID (first field from admGetProjectVersion).

versions.png

In this example I would assume 1.5 is the more recent version based on the ID (10101).

https://confluence.cprime.io/display/SIL/admGetProjectVersion 

https://confluence.cprime.io/display/SIL/admGetProjectVersions 

 

I hope that helps.

Kind regards,
Thiago Masutti

Hi Thiago.
To clarify, we need to select the last value from the field in the task. As I understand it, your example is pulling a value from a project. Perhaps there is some way to pull the value out of the task?

Hi Ellen.

If you need to check the latest value assigned to a Jira Issue, then you may use getFieldChanges .

 

The below will get all the changes applied to the field.

getFieldChanges("SCRUM-14", "Fix Version")

jira-sil-versions.png

 

The below script will get the latest value for the same field.

JFieldChange[] changes = getFieldChanges("SCRUM-14", "Fix Version");

JFieldChange latestChange = changes[0];
date newest = latestChange.changeDate;

for (JFieldChange change in changes) {
if (change.changeDate > newest) {
latestChange = change;
}
}

return latestChange;

jira-sil-versions-2.png

Kind regards,
Thiago Masutti

Thanks, it worked!
How to get version name? For further actions with the script, we need to pull out the version name. For example, set the variable:
string lastVersion;
and assign the resulting value to it, in your example it is "Version 3.0"

Hi Ellen.

That returns a JFieldChange object. The structure is detailed in https://confluence.cprime.io/display/SIL/Predefined+structure+types#Predefinedstructuretypes-JFieldChange 

You may use one of the following depending on what you need.

latestChange.newVal

latestChange.newValString

 

jira-sil-versions-3.png

 

Kind regards,
Thiago Masutti

Hi Thiago.
It worked. Thank you.
I noticed that if, when editing a field, the old value is deleted, changed to another value and then saved, then the log is empty. Is there a way around this to always get the latest value?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

Confluence: Where work and wellness meet

Feeling overwhelmed by the demands of work and life? With a 25% increase in the prevalence of anxiety and depression worldwide during the pandemic, for most of us, it’s a resounding yes . 🙋‍♀️ ...

757 views 5 21
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you