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 change the last updated or the last modified date on a JIRA ticket?

Is it possible to do that without making the changes on the DB directly? I tried to import CSV method. That works only on date created but not on date modified. I believe the import is changing the date as I list in the CSV and then updating the last updated time to current date and time since the update was made.

 

2 answers

1 accepted

0 votes
Answer accepted

If you have Scriptrunner or something that let you write scripts using Jira Java Api, you can try using MutableIssue.setUpdated(Timestamp) function. then you have to store the value using MutableIssue.store()

Thanks. I will have to learn how to do this.

Do you know if there are any sample scripts somewhere?

If you create a post function. I think your script will look like this

java.util.Date now = calendar.getTime();

java.sql.Timestamp currentTimestamp = new java.sql.Timestamp(now.getTime())

issue.setUpdated(currentTimestamp)

issue.store()

I did not try the code. There can be typos.

This worked. Thanks a lot

Hello,

 

the accepted solution uses the issue.store() method , which is deprecated:

store() Deprecated.  Use the Object's Service or Manager to save values. Since v5.0. DO NOT USE THIS as it overwrites all the fields of the issue which can result in difficult to reproduce bugs Prefer to use QueryDslAccessor to change only needed fields

 

There are three ways to update an issue : listed in this excellent article : https://community.atlassian.com/t5/Agile-articles/Three-ways-to-update-an-issue-in-Jira-Java-Api/ba-p/736585

I tried them out :

* IssueManager : use the setUpdated() with a Timestamp on the Issue object , then  use the updateIssue() method of the IssueManager.  This does not work, the Updated field will always be overwritten with the current date.

* CustomField:  the Updated field is not a customfield, so that does not work.

* IssueService: the IssueInputParameters class does not have a method to set the Updated field.

 

So I did not find a way to safely update the Updated field of an issue. Like the deprecation notice suggest, your best bet seems the QueryDslAccessor and write in the DB directly.

 

Now, as an extra : I will add my use case in the hope it can help somebody in the future. I was searching for a way to update an issue without changing the "updated" field, which led me to this issue (did not find anything else).   

This is possible by using the second method, with CustomField.

Something like this :

yourCustomField.updateValue(null,issue,new ModifiedValue("",newValue),new DefaultIssueChangeHolder())

Using this method is different then the rest, the action not registered as an update : the Update field does not change , you don't have to specify an ApplicationUser to link the action to, there is no update in the history tab.

 

hope this helps someone.

Hi @Loïc Dewerchin ,

Thanks for this useful info.

I've also been looking for a couple of days for a way to just update "modified date" of an issue, without success. It seems the only way is writing in the DB directly.

Now, I'm facing a new scenario where I need to set value for a new CF in all existing issues. Responsible of the project doesn't want all updated dates set to "now". I think this is a common scenario. Atlassian should give us an easy way to achieve this even if it was scripted method.

Last thing, a full sample code of your method can be found here: https://community.atlassian.com/t5/Answers-Developer-Questions/Set-JIRA-Service-Desk-Custom-Field-in-groovy/qaq-p/518940.
Hope it can help someone else.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

The add-in you’ve been waiting for: Jira Cloud for Excel 🙌

Introducing Jira Cloud for Excel Here at the product integrations team at Atlassian, we are thrilled to announce the new Jira Cloud for Excel add-in! This add-in lets you export Jira data directly ...

840 views 5 22
Read article

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