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

0 vote
Joshua Yamdogo Community Champion Aug 15, 2017

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,321 views 14 20
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot