I want to populate a custom field of type Date-Time picker with Current Date and Time and I want to take the time factor only for hours and minutes i.e. in the format "dd.MM.yy HH:mm" and exclude seconds and milliseconds. The functionality has to implemented a Custom Script Post Function. Kindly suggest the groovy script for same.
Per your description, I believe you are needing to add a post function to automatically update a date & time custom field with the current date and time of your instance timezone. Is it correct?
If you re using JIRA Server, I believe you can achieve this need by using Scriptrunner App and use the following Groovy script as a template in your post function:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.event.type.EventDispatchOption import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.UpdateIssueRequest import java.sql.Timestamp issue.setCustomFieldValue( ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("customFieldname") , new Timestamp() ) //only for create transition /* ComponentAccessor.getIssueManager().updateIssue( ComponentAccessor.getJiraAuthenticationContext().getUser() , issue , UpdateIssueRequest.builder().sendMail(false).eventDispatchOption(EventDispatchOption.ISSUE_UPDATED).build() ) */
If you are using JIRA Cloud, you can use the Update Custom field post function and add the value %%CURRENT_DATETIME%% to it.
P.S: you can use this same post function in JIRA Server too, however, you must install the JIRA Suite Utilities app to use that Post Function.
Let me know if this information helps.
Hello @Petter Gonçalves
I am sorry, that did not help as I did not want the seconds and milliseconds part of the current time.
Following script helped me to resolve the issue.
Thank you for taking out your time and responding.
Learn how to use two new reports for next-gen projects in Jira Cloud: Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...
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