Hey
I have a challenge, where a transaction, should change a Custom field "Release Date" of the issue based on another custom field "Recurrence" and Due date.
This field have have different periods (weekly, monthly, etc.)
Ex: If due date: 1/16/2016, Recurrence: monthly,
Expected result: Release Date: 2/16/2016
Anyone know a way to solve this?
I found a similar link here, but unable to update custom date field
My Script:
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import java.text.SimpleDateFormat
import com.atlassian.jira.issue.comments.CommentManager
Issue issue = issue
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager cfManager = componentManager.getCustomFieldManager()
CommentManager comManager= componentManager.getCommentManager()
String value = issue.getCustomFieldValue(cfManager.getCustomFieldObjectByName("Recurrence"));
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Release Date'};
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy/MM/dd")
String originalDueDate = dateFormatter.format(issue.dueDate)
Calendar newDueDate = Calendar.getInstance()
newDueDate.setTimeInMillis(issue.dueDate.time)
boolean update = true
switch (value){
case "Bi-Weekly":
newDueDate.add(Calendar.WEEK_OF_YEAR, 2)
break
case "Monthly":
newDueDate.add(Calendar.MONTH, 1)
break
case "Weekly":
newDueDate.add(Calendar.WEEK_OF_YEAR, 1)
}
issue.setCustomFieldValue(cf, new DueDate)
Hello,
How are you using this script (as a listener, post function, etc.)?
Jenna Davis
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.