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?
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).
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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")
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;
Kind regards,
Thiago Masutti
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
Kind regards,
Thiago Masutti
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.