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

Could you write an automation to find out who last edited a specific field?

Kelly Arrey
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.
February 16, 2023

Hi Community,

Could automation (on Jira Software Cloud) figure out who was the last person to edit a specific field, and set a label if that person belongs to a specific Jira group? Is that even possible? If so, could someone outline approximately what that would look like?  I would run the rule against a JQL filter as part of a one-time cleanup effort. Thanks for any ideas you can offer.

Kel

3 answers

2 accepted

7 votes
Answer accepted
Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 16, 2023

Ohai @Kelly Arrey and @Mikael Sandberg ...

*TECHNICALLY* you could use the REST API to get the changelog for every issue, like this:

https://YOURSITE.atlassian.net/rest/api/3/issue/BUG-5?expand=changelog

And then, maybe, you could filter every change for a specific field...

And then, maybe, you could grab the _last_ of those changes...

And then, maybe, you could identify the author of that change...

And then you could then do a check if that author is in a specific group

And IF SO, apply the label.

But this would all be a little hairy, for sure.

Maybe I'll give it a go later tonight. :-}

Kelly Arrey
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.
February 16, 2023

Thanks @Darryl Lee that sounds pretty hairy alright. Thanks for thinking about it but please don't spend any more time on it. 

Like Dave Liao likes this
Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 16, 2023

Heh, I couldn't help myself. Got it to work, with the following caveat:

  • It only works if the field change was within the most recent 100 changes to the issue

Anywho, we start with a Web Request to the Jira API:

https://YOURSITE.atlassian.net/rest/api/3/issue/{{issue.key}}?expand=changelog

Then we create a variable that I'm calling recentFieldChangers. What it's doing is getting the most recent changes to the issue (it maxes out at 100, hence the limit*), and checks to see if it is for the field Checkboxes. If so, then it outputs the accountId for whomever made that change (the author), and separates these accountIds with a semicolon.

{{#webResponse.body.changelog.histories}}{{#if(equals(items.get(0).field, "Checkboxes"))}}{{author.accountId}}{{^last}};{{/}}{{/}}{{/}}

Then I use the split function to turn that text string of semicolon-separated accountIds into a "list" object that I can select the first of:

{{recentFieldChangers.split(";").first}}

This is then fed to another web request to check if that user is in the selected group. (Automation does have a function to check if a user is in a group, but it can only be used against user fields in an issue, not arbitrary values.)

So that web request looks like this:

https://YOURSITE.atlassian.net/rest/api/3/user?accountId={{recentFieldChangers.split(";").first}}&expand=groups

I then create a variable called groupMatch. It is going through all the groups for that accountId from above, and checking to see if it matches the group named "shift2", and if so, it outputs "shift2":

{{#webResponse.body.groups.items}}{{#if(equals(name, "shift2"))}}shift2{{/}}{{/}}

And so, the last (heh) step is, compare whether {{groupMatch}} equals "shift2" and if so, then do whatever you need to do. In your case, apply a label.

Here's a picture of what this all looks like:
Screen Shot 2023-02-16 at 9.31.32 PM.png

Notes:

* There actually isn't a limit to the number of changes you can view. But I'm using the issue API endpoint with the expand parameter. To check issues with more than 100 changes, you would have to figure out how to do pagination in the changelog API endpoint to go through each batch of 100 changes, AND they are sorted in chronological order, so you'd have to go through them backwards. I'm bad at doing this with real scripting languages, much less this "pretend" one. :-}

Like # people like this
Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 16, 2023

OH, and for your purposes, you would probably still manually trigger it, but run it against a JQL lookup, so then:

Screen Shot 2023-02-16 at 9.34.53 PM.png

Like # people like this
Kelly Arrey
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.
February 17, 2023

Wow! Thanks again @Darryl Lee. I’m going to take some time to digest this and report back.     

Like # people like this
Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 17, 2023

Heh, yeah, I realize it's a bit much. But hopefully you or somebody else can make use of it!

Like Dave Liao likes this
3 votes
Answer accepted
Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 16, 2023

Yes and no. You can set up the rule to trigger on when the field is changed and then check and see if {{initiator}} is in the specific group. But you cannot use a one-time rule to get the history of the issue to see if the user made the change.

Kelly Arrey
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.
February 16, 2023

Thanks @Mikael Sandberg 

Dave Liao
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 17, 2023

I love how there are multiple correct answers in our world. 💙

Like Kelly Arrey likes this
1 vote
Yuliia_Borivets__SaaSJet_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
February 17, 2023

Hi @Kelly Arrey 

I'm not good with automation, but as an alternative solution, I can suggest Issue History for Jira app. Here, you can track Updated by field, so you will see what changes some person has made to the specific field. All standard and custom fields can be added to the report.

Jira updated by.png

The app is developed by my team. You can try free online demo to see how it works.

Kelly Arrey
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.
February 17, 2023

Thanks @Yuliia_Borivets__SaaSJet_, good to know! 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events