if a Sprint value is added/updated to a User story on either Create/Edit screen,
then the start date and due date fields for that US should be updated with the start and end date of the assigned Sprint
Any thoughts on this?
Hello Mihai,
I think I understand where you wanna go there but in real life, all user stories do not start and end during the same time frame within the same sprint. Some user stories might get started in the middle of the sprint, and some not even finished.
I guess you would like to reach for consistency in these dates, and not update them manually.
By the way, you can get the sprint dates in the sprint reports, and from there all the related user stories.
Best regards,
Hi Mihai,
I wrote this script some years back and could be useful to you. This goes to the Behaviours part of the ScriptRunner plugin in JIRA and someone good with java date/time libs can perhaps optimize it. Also a part of this I found it online, so credit to those too.
Hope this helps!
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.Issueimport com.onresolve.jira.groovy.user.FormFieldimport com.onresolve.jira.groovy.user.FieldBehavioursimport groovy.transform.BaseScriptimport static com.atlassian.jira.issue.IssueFieldConstants.*import com.atlassian.greenhopper.service.sprint.SprintManagerimport com.onresolve.scriptrunner.runner.customisers.JiraAgileBeanimport com.onresolve.scriptrunner.runner.customisers.WithPluginimport com.atlassian.greenhopper.service.sprint.Sprint//import java.sql.Timestamp//import java.text.SimpleDateFormat;//import java.util.Date;//import java.time.format.DateTimeFormatter//import java.text.SimpleDateFormat//import java.time.LocalDateimport org.joda.time.DateTimeimport com.onresolve.scriptrunner.runner.customisers.PluginModuleCompilationCustomiser//@BaseScript FieldBehaviours fieldBehaviours@WithPlugin("com.pyxis.greenhopper.jira")@JiraAgileBeanSprintManager sprintManagerList<String> ListProjectNotToInclude = ["GRICCO","SWT154","MKIV","EM","MK2R19","MKVING11","NG9","MK2","WIPS","AF","DSA","EDT07","NG9EM"]if (!ListProjectNotToInclude.contains(issueContext.projectObject.key)){ def sprintFormField = getFieldByName("Sprint") if(sprintFormField.value) //if(sprint && sprint.state == "ACTIVE"){ { Long sprintVal = sprintFormField.value as Long def sprintManager1 = PluginModuleCompilationCustomiser.getGreenHopperBean(SprintManager) DateTime dtStartdate = sprintManager1.getSprint(sprintFormField.value as Long)?.getValue()?.getStartDate() DateTime dtEnddate = sprintManager1.getSprint(sprintFormField.value as Long)?.getValue()?.getEndDate() if (dtStartdate && dtEnddate) { def customField1 = customFieldManager.getCustomFieldObject("customfield_20506") // Start date def customField2 = customFieldManager.getCustomFieldObject("customfield_20507") // End date int intDay1 = dtStartdate.getDayOfMonth() int intYear1 = dtStartdate.getYear() int intMonth1 = dtStartdate.getMonthOfYear() String strMonthPart1 = "" if (intMonth1 == 1) strMonthPart1 = "Jan" else if (intMonth1 == 2) strMonthPart1 = "Feb" else if (intMonth1 == 3) strMonthPart1 = "Mar" else if (intMonth1 == 4) strMonthPart1 = "Apr" else if (intMonth1 == 5) strMonthPart1 = "May" else if (intMonth1 == 6) strMonthPart1 = "Jun" else if (intMonth1 == 7) strMonthPart1 = "Jul" else if (intMonth1 == 8) strMonthPart1 = "Aug" else if (intMonth1 == 9) strMonthPart1 = "Sep" else if (intMonth1 == 10) strMonthPart1 = "Oct" else if (intMonth1 == 11) strMonthPart1 = "Nov" else if (intMonth1 == 12) strMonthPart1 = "Dec" getFieldById("customfield_20506").setFormValue(intDay1 + "/" + strMonthPart1 + "/" + intYear1) // Start date //getFieldById("customfield_20506").setFormValue("1/Jan/2019") int intDay2 = dtEnddate.getDayOfMonth() int intYear2 = dtEnddate.getYear() int intMonth2 = dtEnddate.getMonthOfYear() String strMonthPart2 = "" if (intMonth2 == 1) strMonthPart2 = "Jan" else if (intMonth2 == 2) strMonthPart2 = "Feb" else if (intMonth2 == 3) strMonthPart2 = "Mar" else if (intMonth2 == 4) strMonthPart2 = "Apr" else if (intMonth2 == 5) strMonthPart2 = "May" else if (intMonth2 == 6) strMonthPart2 = "Jun" else if (intMonth2 == 7) strMonthPart2 = "Jul" else if (intMonth2 == 8) strMonthPart2 = "Aug" else if (intMonth2 == 9) strMonthPart2 = "Sep" else if (intMonth2 == 10) strMonthPart2 = "Oct" else if (intMonth2 == 11) strMonthPart2 = "Nov" else if (intMonth2 == 12) strMonthPart2 = "Dec" getFieldById("customfield_20507").setFormValue(intDay2 + "/" + strMonthPart2 + "/" + intYear2) } else { getFieldById("customfield_20506").setFormValue("") // Start date getFieldById("customfield_20507").setFormValue("") return } } else { getFieldById("customfield_20506").setFormValue("") // Start date getFieldById("customfield_20507").setFormValue("") return }}
Hi Elvir, Thank for taking the time! You are right, I just wanted them to be visible on the Plans board, and due to missing start and end date the US cannot be visualized
Awesome!
Oh I see,
In Plan, dates are automatically taken from the sprint start and end date if the these fields are empty.
I am in Jira cloud and this is what I get
Please check your Plan configuration
Elvir, that fixed it!!!! You amazing man!
It looks like you're new here. Sign in or register to get started.