Forums

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

How to get last updated labels value ?

Konstantin Gagač December 18, 2020

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.png objects 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
Nic Brough -Adaptavist-
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.
December 18, 2020

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
Konstantin Gagač December 18, 2020

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

Konstantin Gagač December 18, 2020

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
atlassian, jira product discovery, jpd premium, product management, idea management, product discovery, jira premium, product planning, atlassian community, product development, roadmap planning, product prioritization, feature management

Introducing Jira Product Discovery Premium ✨

Jira Product Discovery Premium is now available! Get more visibility, control, and support to build products at scale.

Learn more
AUG Leaders

Atlassian Community Events