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

Avdhesh Chauhan
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.
March 21, 2012

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 votes
Answer accepted
JamieA
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.
March 22, 2012

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.

0 votes
dasd asfasdf January 14, 2013

spam

0 votes
Avdhesh Chauhan
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.
March 22, 2012

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.

Avdhesh Chauhan
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.
March 22, 2012

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.

JamieA
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.
March 22, 2012

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)

Avdhesh Chauhan
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.
March 25, 2012

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.

JamieA
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.
March 25, 2012

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

Avdhesh Chauhan
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.
March 25, 2012

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.

JamieA
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.
March 25, 2012

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.

Avdhesh Chauhan
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.
March 25, 2012

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???

JamieA
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.
March 25, 2012

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.

Avdhesh Chauhan
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.
March 26, 2012

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
TAGS
AUG Leaders

Atlassian Community Events