If a user inputs a custom field date picker, how can I script it into a date time?

For example - on the 'create' form a user selects a date picker to populate customfield 'Meeting Date' - say 8/10/2017. How can I write a script to automatically populate a customfield 'Meeting Start' with a fixed time, to make it '8/10/2017 08:30:00'? So it would be set at 8:30am for whatever date the user picks

 

Thanks for any feedback!

1 answer

This widget could not be displayed.

You could do with this in a script field. I wrote the following script that will:

  • Get the value from a Date Picker field ("Meeting Date")
  • Format that value to be "month/day/year 8:30:00"
  • Displays value in the scripted field ("Meeting Start")
import com.atlassian.jira.component.ComponentAccessor
import java.text.SimpleDateFormat
enableCache = {-> false}
def customFieldManager = ComponentAccessor.getCustomFieldManager()
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy 08:30:00")
def meetingDate = customFieldManager.getCustomFieldObjectByName("Meeting Date")
return sdf.format(issue.getCustomFieldValue(meetingDate))

 

Screen Shot 2017-08-15 at 12.56.39 PM.png

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

139 views 2 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you