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.
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())
I did not try the code. There can be typos.
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.
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 ...
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