Script Runner - How to set a date picker custom filed to the current day

I want to know how to set a date picker custom filed to the current day? I tried a lot of way but no one works.

For example:

Date now = new Date()

Date cfDate = new Date(cfValues['DateFieldA'].getTime())

or

issue.setCustomFieldValue('DateFieldA', new Date())

Thanks very much!!

1 answer

0 vote
Henning Tietgens Community Champion Mar 10, 2014

Take a look, which object you get if you get the custom field value and try to submitt an object of the same class while setting the custom field.

To get the class of the returned object use this

log.error cfValues['DateFieldA']?.class?.name

In this case I assume it's a Timestamp. If this is correct, you can try

issue.setCustomFieldValue(cf, (new Date()).toTimestamp())

cf is the customfield not the name of the customfield. See my comment here to see how to get the customfield object.

After updating the issue normally you have to save the issue, see here on how to do this.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published 14 hours ago in Off-topic

Get to know our Atlassian User Group Leaders from Bengaluru, India

Meet @Dinesh Dhinakaran, @Vishnu Vasudeva, @Rajeev Verma, and Jamshid Nalakath: Our extraordinary AUG leaders from Bengaluru, India. These four work together to strengthen the bonds of their local co...

102 views 0 4
Read article

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