Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get sprint start date using Behaviours

Kris Han
Contributor
May 12, 2020

Hi Everyone,

As title, How do I get the sprint start date using Behaviours? Is it possible? Thank you very much!

 

Best Regards,

Kris

1 answer

1 accepted

0 votes
Answer accepted
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 12, 2020 edited

Hi,

Below code might help. But, bear in mind that an issue can have multiple sprint values, and this script returns the date of first sprint.

Sorry that I was not able to test the code, but it would guide you to a running version ;) 

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def sprintCf = customFieldManager.getCustomFieldObject(10000) // id of Sprint customfield


return issue.getCustomFieldValue(sprintCf)?.startDate?.first()?.toDate()
Kris Han
Contributor
May 12, 2020

Hi,

Thanks for your answer. However, It showed an error which is "issue is not undeclared". How should I fix this error? Thank you very much!

 

Best Regards,

Kris 

Kris Han
Contributor
May 12, 2020

Hi, 

Even I changed it to underlyingIssue, it will also show there is no property for startdate. Please help me on it. Really appreciate! 

Capture.JPG  

Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 13, 2020 edited

Hi Kris,

Ignore that error and try to run the code.

Groovy is a dynamic scripting language in which you can code without defining static types. 

Kris Han
Contributor
May 13, 2020

Hi, 
Thanks for your help and answer. I got what I want. 

Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 13, 2020

Happy to help :) 

Kris Han
Contributor
May 13, 2020

Hi @Tuncay Senturk ,

Sorry to bother you again, 

Do you know how to get sprint start date using script field? Thank you very much!

 

Best Regards,

Kris

Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 13, 2020

No worries!

It should be the same way actually

Kris Han
Contributor
May 21, 2020

Hi @Tuncay Senturk ,

Sorry to bother you again, 

Is there any way which can fill up the value I caught from the script automatically without any transition? Thank you very much!

Best Regards,

Kris 

Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 21, 2020

Hi @Kris Han 

No worries, you're not bothering at all.

You can use the same code in anywhere (scripted custom field, scripted post function, behaviors, even in listeners).

For instance you can implement your own scripted listener in which you can listen to any issue change and pick Sprint start date and do whatever you want. Only one or two lines might be added to your script accordingly.

Kris Han
Contributor
May 21, 2020

Hi @Tuncay Senturk ,

I copied the entire script to Listener but I got lot of errors. Could you help me to give me some example? Thank you very much!

 

Best Regards,

Kris

Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 21, 2020

You need to provide more info regarding your demand. 

But you can use below code to start

import com.atlassian.jira.component.ComponentAccessor

def issue = event.issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def sprintCf = customFieldManager.getCustomFieldObject(10000) // id of Sprint customfield

def sprintStartDate = issue.getCustomFieldValue(sprintCf)?.startDate?.first()?.toDate()

// then use this sprintStartDate on whatever you want to do.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, dance, gamification, badge, razzle dazzle, team '25 anaheim

Earn a one-day badge today and do the Atlazzle Dazzle! 🕺

Today only! Share what you’re the most excited about for Team ‘25 or just dance out the beginning of a new quarter with us.

Comment the post
AUG Leaders

Atlassian Community Events