Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptRunner Post-function add 1 month to date field and update date field

Chris Ghazanchian
Contributor
March 24, 2018

I would like to add 1 month to a custom date field (Next Cycle Date) and then update that date field upon a workflow transition (post-function).

I have the current script but it's not doing anything, not sure what I am doing wrong.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.UpdateIssueRequest
import java.text.SimpleDateFormat

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()

SimpleDateFormat dateFormatter = new SimpleDateFormat("dd/MMM/yy");
java.sql.Timestamp nextCycleDate = (java.sql.Timestamp)issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_10603")) //get current "next cycle date"

nextCycleDate.setMonth(nextCycleDate.getMonth() + 1) //add 1 month to current cycle date to get next cycle date

issue.setCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_10603"), nextCycleDate) //update next cycle date

 

2 answers

0 votes
Jeff
September 2, 2015

Indeed. I was surprised that it let me use the word in the title. But the reason I opened this ticket is the attached screenshot. I was not able to submit the question until I changed the words "assignee" and "assigned" to "asignee" and "asigned".

Screen Shot 2015-09-01 at 3.40.48 PM.png

Jeff
September 2, 2015

Perhaps it is only a problem when the word is capitalized? Like "Assigned" or in a bullet?

Radu Dumitriu
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 Champions.
September 2, 2015

ok, then. There's a report a bug link in the bottom of the page. Use it, it's more useful than 'stupid blacklist'

0 votes
Radu Dumitriu
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 Champions.
September 2, 2015

Answer: Blacklist is not stupid.

Proof: This question exists. Therefore, Answers lets you use the word 'assignee'. This answer contains the word  'assignee'. Therefore, blacklist is not stupid.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events