How to set the due date of linked issue based on the value of a date custom field from the original issue?

Tsol
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.
April 2, 2012

Hi everybody,

i'm using a post function for creating multiple issues. The original issue has a date custom field. In some of the new created issues i would like to set as due date the value of the date custom field from the original issue. At the moment i can't do it.

In some others i would like to set as due date +/- 1 day the value of the date custom field. I can;t do even that.

The date custom field i have is called: Starting date

the syntax i have used is:

issue.duedate = ${cfValues['Starting Date']}

i'm getting the following error:

The staring date field is mandatory. So there in no way to be blank

the order that i have put the functions are:

Thanx in advance,

Kostas

1 answer

1 accepted

3 votes
Answer accepted
Dieter
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.
April 3, 2012
issue.setDueDate(cfValues['Starting Date']) should copy the value of the custom field into due date of the cloned issue. Else if cfValues[...] does not return a result, you could write the following to get the custom field object: def cf = customFieldManager.getCustomFieldObjectByName('Starting Date') and then use: val = issue.getCustomFieldValue(cf) Finally use issue.setDueDate(val)
Tsol
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.
April 3, 2012

The first solution didn't copy the value but the second solution works perfectly. Any idea how to reduce or increase a date field value?

Thanx a lot


Tsol
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.
April 3, 2012

after some experiments i found my way to modify the date. For example if i want to reduce the value by 1 day i'm using the following:

def cf = customFieldManager.getCustomFieldObjectByName('Starting Date')
val = issue.getCustomFieldValue(cf) - 1
issue.setDueDate(val)

Suggest an answer

Log in or Sign up to answer