How to Update a Date type custom field value by one month using groovy Script post function?

Hi,

I have a date type custom field, i want to update its value by one month from the existing one how can i accomplish this using post function??

3 answers

1 accepted

0 vote

See https://answers.atlassian.com/questions/40763/how-to-set-a-date-time-customfield-by-postfunction - that code is more verbose than necessary but should get you on the right track.

Thanks a lot Jamie but this code is updating the date field value by current date but if want to update the value by current date+1 month then how can i use that code?

please guide me.

Let us suppose i have a custome field Release Date : 23/Mar/12 now i want a groovy which will automatically set this value to 23/Apr/12 when i will execute the transition.

Please help me to get out of this.

You can find this on the interwebs, it's the same in groovy as java more or less. Something like:

def cal = Calendar.getInstance()
cal.add(Calendar.MONTH, 1)

Thanks Jamie, But is not the Solution of my problem,

I want like this

Let us suppose i have a custome field Release Date : 23/Mar/12 now i want a groovy which will automatically set this value to 23/Apr/12 when i will execute the transition.

I need a simple code for this.

the code you have given is not working.

My psychic remote debugging skills are failing me today... so we will need more info than "not working".

it is throwing exception saying error in code can not find Calander and getInstance() still i have also given with package name still it is giving same error.

the code you have given in that where we are using the custom field name and id then how we can update the particuler custom field value.

Can you post the entire code you are using, with correct formatting. To gist.github,com if you don't know how to do the formatting here.

def cal = Calendar.getInstance()
cal.add(Calendar.MONTH, 1)

where we are giving custom field name or id??

How will system identify to which custom field we want to update???

That was just an example for adding a month to the current date. The other code has an example for updating a custom field. You don't need to import Calendar when using groovy.

Soory sir i can not upload the code due to some security reasons but i can tell you the scenerio,

i have one custom field named Release date it is having some value suppose 20/May/2012 now i have one transition in the jira flow and i want to update this custom field bvalue by one month that is 20/Jun/2012.

please help me.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Apr 10, 2018 in Marketplace Apps

Learn about how Stefan K. built one of the *first ever* Marketplace apps

In this post you will discover more about the evolution of K15t software, some big topics they're currently focusing on in the app space, and a rare (not not funny!) photo of founders Mike Cannon-Bro...

13,108 views 11 24
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