Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Custom Field showing Last Modified User of an issue

I found some of code in the forum for a scripted field but can not get it to work with the latest software. 

Any help appreciated 

import com.atlassian.jira.component.ComponentAccessor

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def changeItems = changeHistoryManager.getAllChangeItems(issue)

if (changeItems?.size() > 0) {
    def userUtil = ComponentAccessor.getUserUtil()
    def userkey = changeItems.sort(false).last().getUserKey()
    userUtil.getUserByKey(userkey)
} else {
    null
}

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Randy
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.
Mar 23, 2018

scripted fields only fire on transitions.  and if you are okay with it being updated on transition then you dont even need SR to track.

 

Just add a custom field and add a "Update Issue Custom FIeld" post function with the field selected and this for the value: '%%CURRENT_USER%%'

Thanks for the feedback the best option would be a listener which I have not found any good examples as of yet 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 23, 2018

No, scripted fields are updated at a lot of other times.   It's an oversimplification, but you can almost always assume a scripted field is updated when the issue is indexed.  Transition, comment, edit, move, etc.

Nic - do you have any suggestions to the code listed as it does not appear to work 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 25, 2018

Apart from it not explicitly returning a value for the field to work with (as it's pseudo code, or code not intended for a field) what is it doing?

Randy
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.
Mar 26, 2018

Ah that's good information Nic.  I didnt realize it also fired on comment/edit/move/index.  Thanks

TAGS
AUG Leaders

Atlassian Community Events