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,559,698
Community Members
 
Community Events
185
Community Groups

Place Data From One Custom Field to Another Custom Field after adding months to it

Edited

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import java.sql.Timestamp

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey('xxxx-xxxx')

def months = 1
def dateACF = customFieldManager.getCustomFieldObject("customfield_xxxx")
def dateAValue = issue.getCustomFieldValue(dateACF) as Date
log.warn dateACF
log.warn dateAValue

def dateB = Calendar.getInstance()

dateB.setTime(dateAValue)
dateB.add(Calendar.MONTH, +months)
dateB.getTime()

log.warn dateB.getTime()

LOGS:

2021-09-08 11:44 WARN [runner.ScriptBindingsManager]: EMP Effective Date 2021-09-08 11:44:08,595 WARN [runner.ScriptBindingsManager]: 2021-08-02 00:00:00.0 2021-09-08 11:44:08,596 WARN [runner.ScriptBindingsManager]: Thu Sep 02 00:00:00 MDT 2021

1 answer

1 accepted

0 votes
Answer accepted
Leo
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 09, 2021 • edited

Hi @Justin Mele,

if I understood correctly, you want to add months to fetched value. if so you can try below snippet

def dateB = dateAValue as Date
dateB.setMonth(dateB.getMonth() + months) 

 hope this helps

 

BR,

Leo

Leo,
      I did get that part of the script figured out. thank you! what I am trying to do now is place them in another custom field as an employee review. So it would go out 30, 60, 90, 180, and 12 months from their effective date.

Thank you,

Justin

Like Leo likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events