Get sprint start time from a story using calculated customfield.

Hi,

I know how to get the sprint start time of a story using scripted field with the below code

 

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()

But now I need to get the same result using 'JIRA Misc Custom Fields' plugin. Any ideas?

1 answer

This widget could not be displayed.

Unfortunately, JMCF doesn't support Groovy, you need to use some more traditional Java syntax.

You can try the following script:

if (issue.get("customfield_10004")==null || issue.get("customfield_10004").getStartDate() == null)
  return null;
return issue.get("customfield_10004").getStartDate().getFirst().toDate();

although I'm not quite sure about the "first()" method - is it a method or a property?

Thanks for the response David. The first() returns the first value in the array. Each story can be in multiple sprints and I need the start time a story gets added to the sprint and the sprint is started. 

I've done a workaround now by using both scripted fields and JMCF. The JMCF simply returns the value in the scripted field. Not ideal but it's the only workaround I found now.

 

<!-- @@Formula:
sprintCf = issue.get("customfield_13000");
if (sprintCf==null)
 return null;
return sprintCf;
-->

 

Cheers,

Gaj

Then you could try my code but replace "getFirst()" with "get(0)" or "[0]". 

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
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

155 views 2 0
Join discussion

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