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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Update a date custom field considering the Due Date populated date

Hi Team,

 

We have a requirement to update a custom filed "Due Date Provided On" with the date on which "Due Date" field is populated.

Below is the actual requirement, how can we implement this?

 

Case“Due Date” field in JIRA“Due Date Provided On” field in JIRA
XYZ-123 is created with no Due Date<empty><empty>
User A adds the Due Date of 1-Jan-2020 to XYZ-123 on the 31-Oct-201901/01/202031/10/2019
User B deletes the Due Date on the 5-Nov-2019<empty>31/10/2019
User A adds the new Due Date of 5-Jan-2020 to XYZ-123 on the 10-Nov-201905/01/202010/11/2019

1 answer

0 votes
Antoine Berry Community Leader Nov 20, 2019

Hi @Neenu jose ,

Here is a script you can use for your need : 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

import java.sql.Timestamp

def dueDateChanged = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "duedate"}

if (issue.getDueDate() != null){
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def dueDateProvidedOnId = 12500
def dueDateProvidedOn = customFieldManager.getCustomFieldObject(dueDateProvidedOnId)
def dueDateProvidedOnValue = issue.getCustomFieldValue(dueDateProvidedOn)

dueDateProvidedOn.updateValue(null, issue, new ModifiedValue(dueDateProvidedOnValue, new Timestamp(new Date().getTime())), new DefaultIssueChangeHolder())
}

Use a script listener on the "Issue Updated" event, and any additional event where you are likely to change the due date.

Also add a script post function in the create transition, use this script while removing this line :

def dueDateChanged = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "duedate"}

Let me know if that helped.

Antoine

Antoine Berry Community Leader Nov 22, 2019

hi @Neenu jose ,

Did that work for you ?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Do Not Lose your Customer’s Trust

Missing deadlines is one of the biggest problems every team lead wants to avoid when dealing with managed services. When the customer contracts your company to help with IT services it is expected th...

24 views 0 0
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you