Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Connor Sims August 10, 2017

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 votes
Joshua Yamdogo @ Adaptavist
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.
August 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 Sign up to answer
TAGS
atlassian, jira service management, jsm webinar, ai in jsm, opsgenie integration, incident management, virtual agent, atlassian intelligence, ai-powered service desk, it operations, atlassian learning, service management webinar, team '25 recap

What’s new in Jira Service Management 🤔

Discover how Atlassian is revolutionizing service management with cutting-edge solutions for AI-powered support, HR Service Management, or DevOps connectivity.

Register here ⬇️
AUG Leaders

Atlassian Community Events