Groovy script to change Created Date

KPAH
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.
March 11, 2013

Hi.

Could anyone provide a working groovy (or any other Script Runner-supported language) script to change the created date of a given issue (ISSUE-ID)?

Thanks in advance

2 answers

1 accepted

0 votes
Answer accepted
KPAH
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.
March 11, 2013

Ok, I ended up stopping the database and runnin a SQL script to correct dates. The donwtime was only 2 minutes. And then I reindexed the project using Script Runner as suggested by Henning Tietgens [CTS Eventim AG]

0 votes
JamieA
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.
March 11, 2013

Have you tried called

issue.setCreated(timestamp)

in a transition?

KPAH
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.
March 11, 2013

hm, that means I have to edit the workflow right?

We have like 35 issues re-entered manually to the new project, they obviously have created dates much later then the original was. I just want to run a script for each of them to change the createddate to the original one. else, I would have to stop the DB which is not a very good thing.

Henning Tietgens
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.
March 11, 2013

So you can try this from the Script Runner console... use componentManager.issueManager to get a MutableIssue object for each of the 35 issues and set the created date and store() the issue. Maybe you have to run a reindex on these issues after that, you can use the builtin reindex script from Script Runner for that.

JamieA
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.
March 11, 2013

Would have been good if you had given the background in the question.

demian kurejwowski January 5, 2016

the documentation say that store() is deprecated, how should be done instead?

Henning Tietgens
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.
January 5, 2016

"Deprecated" doesn't mean it's not working, only that's maybe not working in one of the next releases. A non-deprecated way to modify an issue is to use IssueService, but I'm not sure if it's possible to change the created date this way, because when an issue is created should be determined by the system...

JamieA
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.
January 5, 2016

the store() is usually redundant... if you have your function towards the top of the list, the issue will be "stored" and reindexed later in that workflow function.

Suggest an answer

Log in or Sign up to answer