Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get last updated labels value ?

Hi, 

i am trying to get  last updated labels value from script runner using ChangeHistoryItem,
i able to get created time, field name, but can't get from/to values.... 

image.pngobjects are null

when i query label collection -  it's arranges labels in collection not by adding time, but by name ascending, so stopped on this. 

please guide me how to retrieve last added/removed label name 

 

 

1 answer

1 accepted

0 votes
Answer accepted

This is quite a hard one to explain, but there is a subtle difference between changing a field value and changing the content of a field value.

Jira stores labels in a list which then becomes the value of the field.  The change history records changes to the values of fields, including the to and from.  For simple values, this works fine - string "abc" changed to string "cba" or number changed from "42" to "27".  The date and time of the change comes from the record that you changed it.  Same for lists too - list [a, b, c] changed to list [a, b, c, d]  But note that the record is of the change of the list, not a record of what was added or removed from the list.

So, simply put, the data you are trying to find simply isn't there.  You've got a record of the change of the list, but not that specific items in it were added or removed.

To establish when a label was added, you will need to

  • read the change history backwards in time for every change of label,
  • get both the to and from list it and compare the lists, working out what items were added or removed.  If it's the label you are interested in being added to it, then you use the change date as the "added date", and stop looping
  • Go to the previous change and repeat the comparison
  • If you don't find a change at all, then your label was added at issue creation time

hi, thanks, but issue is that from / to are completely empty. they are not even lists... 

looks like i found way how to get what you were described 

i managed to get difference from  getChangeHistoryById by changeGroupId

changeHistoryManager.getChangeHistoryById(changeItems.last().changeGroupId).getChangeItems()

now able to see new /old values.  

anyway thanks

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS

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