It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to set due date in jira issue automatically from version field release date?

Shagufta Gurmukhdas Nov 22, 2016

I have a custom field which allows selecting versions. From the selected version in the field, the release date should be extracted and that should be set as the due date for an issue created . (say newSubTask ). How to do that?

What I did was:

def versionCF = customFieldManager.getCustomFieldObjectByName("Fix Version(s)")

String valueOfversionType = parentIssue.getCustomFieldValue(versionCF)

Project project = parentIssue.getProjectObject()

Version versionn = versionManager.getVersion(project.getId(), valueOfversionType)

newSubTask.setDueDate(new Timestamp(versionn.releaseDate.time))


But I get the following error:

2016-11-23 10:18:10,909 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2016-11-23 10:18:10,911 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: TPK-129, actionId: 1, file: <inline script>
java.lang.NullPointerException: Cannot invoke method getReleaseDate() on null object


2 answers

2 votes
Vasiliy Zverev Nov 22, 2016

Dear @Shagufta Gurmukhdas, Fix versions is not a custom field. It is a build-in field. To get it you should use 


it returns a collection of all Fix Versions.

Shagufta Gurmukhdas Nov 23, 2016

No, Fix Version/s is the built-in field, but i have created a custom field named Fix Version(s) since I had to make it mandatory in my project and making mandatory the built in field would have made it mandatory for all projects that use it.

So, basically, my field IS a custom field

Shagufta Gurmukhdas Nov 23, 2016

@Vasiliy Zverev can you help with that? with doing it through a custom field?

Vasiliy Zverev Nov 23, 2016
  1. It is possible to make Fix version mandatory into field configuration
  2. Namely trouble is that versionn is null. It means that 

    versionManager.getVersion return null

    Here is modified code

    import com.atlassian.jira.component.ComponentAccessor
    import com.atlassian.jira.issue.Issue
    import com.atlassian.jira.issue.fields.CustomField
    import com.atlassian.jira.project.version.Version
    Issue parentIssue = null
    CustomField versionCF = customFieldManager.getCustomFieldObjectByName("Fix Version(s)")
    Version versionn = versionManager.getVersion(
            , parentIssue.getCustomFieldValue(versionCF))
    if(versionn == null)
    newSubTask.setDueDate(new Timestamp(versionn.getReleaseDate().getTime()))


0 votes
Shagufta Gurmukhdas Nov 22, 2016

Sorry, I have written versionn.getReleaseDate().time, not versionn.releaseDate.time . But anyway, both aren't working

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

6,221 views 22 30
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you