add days to date by behaviour or script runner


1) Add 10 days to custom date field.

2) 10 days will be pulled from a custom field ( number)


Below step using behavior plugin but not working


import com.atlassian.jira.component.ComponentAccessor

import static com.atlassian.jira.issue.IssueFieldConstants.*

def desc = getFieldById("customfield_11002")

def defaultValue = getFieldById("customfield_11003")

def newvalue = defaultValue.getFormValue() as Long




I am not able to access the value of customfield_11003 to store in customfield_11002


 Not interested in using misc custom fields as it is messing up with my custom field view




6 answers

Hi Armar,

For the searcher use the Date Time Range picker. For the template use Date Time Picker.

And in the inline field add the logic. In your case should be something like: 

def dateField = getCustomFieldValue("DateCF")
def numberField = getCustomFieldValue("NumberCF")
def number = numberField?.intValue()

if (number == null || dateField == null)

def result = dateField + number
return new Date(result.getTime())

Please let me know if this works for you.



Amar, As I said, the solution I propose is to use scripted field ( and not a behaviour. As far as I understand you want a custom field which will hold the value of two other custom fields (in your case a date plus a number).

ok... do i need to import any headers

You don't have to import anything in the above script.

/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml [onresolve.scriptrunner.customfield.GroovyCustomField] getCustomFieldValue called from script: No field with ID or name customfield_10620 /sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml [onresolve.scriptrunner.customfield.GroovyCustomField] getCustomFieldValue called from script: No field with ID or name customfield_11106

Apparently there are no custom fields assigned to you project with such names. Please try to add as a param in getCustomFieldValue the name and no the id of the custom field.

you mean def dateField = getCustomFieldValue("Planned date") def numberField = getCustomFieldValue("Number of days") def number = numberField?.intValue() if (!number || !dateField) return def result = dateField + number return new Date(result.getTime()) instead of def dateField = getCustomFieldValue("customfield_11111") def numberField = getCustomFieldValue("customfield_11234") def number = numberField?.intValue() if (!number || !dateField) return def result = dateField + number return new Date(result.getTime())

IT works!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :-)

Now how can i skip the weekend days.. I mean considering only working days.

I suppose the logic should be something like that (in pseudocode): while (i < number) { dateField ++ if (dateField == sunday || dateField == saturday) i -- i ++ }

Thank will work on it... thanks alot for quick reply and complete solution

Hi Thanus. /*import com.atlassian.jira.issue.MutableIssue import java.sql.Timestamp; MutableIssue myIssue = issue; def dateField = getCustomfieldValue("Date") Calendar dateField = Calendar.getInstance() def numberfield = getcustomFieldValue("Days") def number = numberfield?.intValue() if number (!number || !dateField) return dateField.add(Calendar.DATE, number) while ([Calendar.SATURDAY, Calendar.SUNDAY].contains(dateField.get(Calendar.DAY_OF_WEEK))) { def dateField.add(Calendar.DATE,number) } def result = new Timestamp(dateField.gettime()) return new Date(result.gettime())*/ Not working

Have you tried using the JIRA Workflow Toolbox plugin and using the Post Function Math & Date-Time Expression Calculator

I think that will do exactly what you are looking for.


In the Post Function you can use something like


datePart({Customfield_ID(Date)}, LOCAL) + ({CustomField_ID(Number)} * {DAY})

Hi Sy, Thanks for the quick reply. I want the instance update, not transition based update

Hi Amar, Could you please be more specific in what you are trying to achieve, maybe using a scripted field (if you are using script runner) ? What type are your custom fields ?

Hi Thanos, I want to use 1 custom date field value and add it with 2nd custom number field content and populate result into 3rd custom field

Amar, You can have a look at I think a scripted field that depends on the result of 2 other custom fields is what you want. Please let me know if you need any help with the script part Cheers Thanos

Thanos, Is it possible to add the date and number and get a output.. If yes please let me know which import option I need to choose Regards Amar

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
Fadoua M. Boualem
Published 10 hours ago in Trello

Using Trello to manage events

As a Jira power user, I was at first doubtful that Trello could benefit my workflow. Jira already uses boards (ones you can customize!), so why would I even need to use Trello?! In this post you will...

295 views 4 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