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,560,633
Community Members
 
Community Events
185
Community Groups

Determine/Default Custom Date Fields in Form based on Another Custom Date Field

Edited
Kmmaughs
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.
Feb 25, 2020

Hey! I have some date fields I'd like to auto-populate on the Create step based on the input of another date field. For example, I click Create to create a new issue, and I select a Date on one of the date fields. There are subsequent date fields that I'd like to then auto-assign a value to, but I still want the user to be able to override the defaults. 

Here's an example:

1. Click Create to create a new issue

2. Select a date for the custom date field called "Incident Date".

3. See the subsequent custom date field called "Plan Due Date" auto-populate with a date 7 days after the "Incident Date."

The user then has the option to override the value or continue as is before clicking Create to create the issue. 

 

I was playing with using a Behavior, but it's not really working. 

I tested the behavior on both the "Incident Date" field and the "Plan Due Date" field. Here's the server-side script I used:

import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.field.CustomFieldUpdatedEvent
import java.text.SimpleDateFormat
import com.atlassian.jira.datetime.DateTimeFormatterFactory
import com.atlassian.jira.datetime.DateTimeStyle

def IncidentDateField = getFieldById("Incident Date") // Grab the Incident Date

def PlanDate = getFieldById("Plan Due Date") //Grab the Plan Due Date

double dDays = 7 // Defined number of days

if (IncidentDateField.value != null) {
PlanDate.setFormValue(new Date().plus(dDays.toInteger()).format("dd/MMM/yy hh:mm a"))
}

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events