Forums

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

Want to know the user who updated last fixversion field

siva
Contributor
October 13, 2021

Hi there,

I want to know user  who updated last fixversion field in a issue and here we are using script runner plugin and my plan is created scripted type custom field called Last updated fixversion user . So need your help how to create script for that field.  Please help me how to achieve this.

I had this script it shows the last updated fixversion number

import com.atlassian.jira.component.ComponentAccessor
def changeHistoryManager = com.atlassian.jira.component.ComponentAccessor.getChangeHistoryManager()
def old = changeHistoryManager.getChangeItemsForField(issue, 'Fix Version')
return old?.last().fromString

 

But i want the who updated fixversion and how to modify the above script to my requirement.

Fix version script.png

Thanks,

Siva.

3 answers

1 accepted

0 votes
Answer accepted
Tuncay Senturk _Snapbytes_
Community Champion
October 14, 2021

You can try this one

import com.atlassian.jira.component.ComponentAccessor 
import com.atlassian.jira.issue.changehistory.ChangeHistory;
import com.atlassian.jira.issue.changehistory.ChangeHistoryItem;
import com.atlassian.jira.issue.history.ChangeItemBean;


def changeHistoryManager = com.atlassian.jira.component.ComponentAccessor.getChangeHistoryManager()
List<ChangeHistory> changeHistories = changeHistoryManager.getChangeHistories(issue).findAll{ChangeHistory ch ->
ch.getChangeItemBeans().find{it.getField().equals('Fix Version')}
}

if (changeHistories) {
return changeHistories.last().getAuthorObject()
} else {
return null
}
siva
Contributor
October 14, 2021

Hi @Tuncay Senturk _Snapbytes_ 

 

Thanks for the early reply and your script working perfectly and truely appreciated for your help. Once again thank you very much.

 

Thanks

Siva.

Tuncay Senturk _Snapbytes_
Community Champion
October 15, 2021

Pleasure!

I'm glad that it helped.

0 votes
Tuncay Senturk _Snapbytes_
Community Champion
October 14, 2021

Hi @siva 

I will definitely help if you give me a while.

Meanwhile, have you ever checked Enhancer Plugin? It has First/Last Field Change custom field. You can easily set up and use it for viewing/searching without coding even a single line of code.

For the script, I will try to write it whenever I get free.

0 votes
siva
Contributor
October 13, 2021

@Tuncay Senturk _Snapbytes_ 

Please help me how to create script for  user  who updated last fixversion field.

Suggest an answer

Log in or Sign up to answer