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?
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()
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
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.ComponentAccessorimport com.atlassian.jira.issue.Issuedef customFieldManager = ComponentAccessor.getCustomFieldManager()def sprintCf = customFieldManager.getCustomFieldObject(10004)Issue issue = issueissue.getCustomFieldValue(sprintCf)?.startDate?.first()?.toDate()
It looks like you're new here. Sign in or register to get started.