JIRA Agile sprint start date and end date custom field

I am trying to add sprint end date and start date custom fields. I though I could do that by:

1. Adding a groovy scripted field and update it from the database during workflow transition

2. Database values plugin

Any ideas?

2 answers

1 accepted

This widget could not be displayed.

I don't see a problem having a scripted field. Here's code that works for me.

Use the "date time range indexer", and the "date" template:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def sprintCf = customFieldManager.getCustomFieldObjectByName("Sprint")
Issue issue = issue
issue.getCustomFieldValue(sprintCf)?.startDate?.first()?.toDate()

Thanks Jamie, this is brilliant.

Jira 7.2 doesn't seem to like the start date - no such property: startDate for class: java.lang.Object. Do you have an updated code?

Okay this works now for JIRA 7 if I use getCustomFieldObject and use the ID instead of name. 

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def sprintCf = customFieldManager.getCustomFieldObject(10004)
Issue issue = issue
issue.getCustomFieldValue(sprintCf)?.startDate?.first()?.toDate()

 

The problem is just that getCustomFieldValue is declared as returning Object - see https://scriptrunner.adaptavist.com/latest/jira/#_providing_type_information

Hi Jamie, could you explain this I'm not a coder and would like to use script, I have tried this in ira 6.4.4 and 7.1.9 with the same result.

What's the result you're getting? I'm not sure what you need help with to be honest.

Hi, Jamie: 

I'm a newbie on scripts, but your script doesn't work for me, also.

I get this error shown in the image.

Can you help, please?

Thanks.

Antonio.atlassian1.jpgAtlassian2.jpg

That is safe to ignore - it's just that we can't calculate what type of field is returned by getting the Sprint custom field value. We are working on something better.

Thanks, Jamie. So, waiting for news from Adaptavist.

Do you have an idea on when will this be available?

Greetings.

 

I think you misunderstand me. The script should work right now. The type checking errors you can just ignore, or cast to the correct type, but that's more complex.

https://scriptrunner.adaptavist.com/latest/jira/#_static_type_checking

It is clear, now, Jamie.

Thank you very much!

This widget could not be displayed.

1. If you are updating the field during transition - you don't need the scripted field - it would be ok to have readonly field

2. Please also think about development of your plugin with calculated field - as for me it can be easier maintained during upgrade routines.

https://developer.atlassian.com/display/JIRADEV/Creating+a+Custom+Field+Type

https://docs.atlassian.com/jira/latest/com/atlassian/jira/issue/customfields/impl/CalculatedCFType.html

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published Apr 22, 2018 in Jira Software

How-to setup a secured Jira Software 7.9.0 on Ubuntu 16.04.4 in less than 30 minutes

...PermissionsStartOnly=true User=www-data Group=www-data ExecStart=/opt/jira/bin/startup.sh ExecStop=/opt/jira/bin/shutdown.sh TimeoutStartSec=120 TimeoutStopSec=600 PrivateTmp=true [Install] WantedBy...

1,082 views 6 12
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