Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Using Script Runner under Behaviours End date should be auto populated


In need help in script runner. I have 3 date fields such as start date, duration and end date, the end date should auto populated in view screen based on start date + Duration provide in create screen. Please help me with right code to get this output with help of script runner under behaviours.




1 answer

Hi @Linisha Jesh  Instead of behaviour it is better to use scripted “End Date” field. so that once you create the issue, system calculate sum and Put in end date Scripted field. Try below code replace between by addTo 

Replace Lower Date field and higher date field with Start date and duration respectively.

import com.atlassian.jira.component.ComponentAccessor

import java.sql.Timestamp
import java.time.temporal.ChronoUnit

// Get the required component
def customFieldManager = ComponentAccessor.customFieldManager

// The name of the lower date custom field
final String lowerDateCustomFieldName = "Lower Date Custom Field"
// The name of the higher date custom field
final String higherDateCustomFieldName = "Higher Date Custom Field"

// Get the custom field objects
def lowerDateCustomField = customFieldManager.getCustomFieldObjects(issue).find { == lowerDateCustomFieldName }
def higherDateCustomField = customFieldManager.getCustomFieldObjects(issue).find { == higherDateCustomFieldName }
if (!lowerDateCustomField || !higherDateCustomField) { "Could not find one ore more of the provided custom fields"
return null

// Get the date values from both issues
def lowerDateValue = issue.getCustomFieldValue(lowerDateCustomField) as Timestamp
def higherDateValue = issue.getCustomFieldValue(higherDateCustomField) as Timestamp
// Transform both values to instants
def lowerDateInstant = lowerDateValue?.toInstant()
def higherDateInstant = higherDateValue?.toInstant()

// Change the chrono unit to obtain the difference in other time unit.
final chronoUnit = ChronoUnit.DAYS
// Calculate the difference between the lower and the higher date.
lowerDateInstant && higherDateInstant ? chronoUnit.between(lowerDateInstant, higherDateInstant) : null


Source of code :

Hi Vikrant Yadav,

I have already writen script for start date in the transistion to add 20 min to the current time. now i have to fetch this start time + duration to end time with help of behaviour. Can you please help with this..

Thank you,



Hi @Linisha Jesh  you want to update end date field value after a transition? As per the tags it seems that you are using Jira Cloud. In jira cloud behaviour is not available. In cloud You can do It via post function or via listener or use scripted end date field. 

In our organization we are using data center for which i need help

Suggest an answer

Log in or Sign up to answer
Site Admin
Community showcase
Published in Jira Service Management

JSM June Challenge #2: Share how your business teams became ITSM rockstars

For JSM June Challenge #2, share how your non-technical teams like HR, legal, marketing, finance, and beyond started using Jira Service Management! Tell us: Did they ask to start using it or...

227 views 7 7
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