You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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.