Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,551,722
Community Members
 
Community Events
184
Community Groups

Updating a date custom field on workflow transition, with a custom field, due date off set

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)

 

1 answer

0 votes
Jenna Davis
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.
Oct 16, 2017

Hello, 

How are you using this script (as a listener, post function, etc.)? 

Jenna Davis

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events