We are trying to set a custom field(date/time) when an issue is linked with a certain link type direction but only to a certain project. Is there a way to get the created date/time from the history when the issue is linked?
Here is what I have so far but it returns null. if i remove the contains i end up getting all linked history fro the issue.
{code}
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
Issue issue = issue
IssueManager issueManager = ComponentAccessor.getIssueManager()
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def changeHolder = new DefaultIssueChangeHolder()
log.debug "testing"
def time = changeHistoryManager.getChangeItemsForField(issue, "Link").collect { it.to.contains("PC-") }
log.debug(time)
{code}
Hi Kevin,
Try this:
chgHistMgr.getChangeItemsForField(issue, "Link").findAll{it.getTo().contains("PC-")}.collect{it.getCreated()}
This'll return an array of Timestamp objects, each of which represents the time when your issue has been linked to a "PC-...." issue. After that you can use an element from this array (a timestamp object in this case) to populate your date custom field.
Hope this helps.
Thanks Ivan here what i ended up using
if (! PPMTSDvalue && issue.issueType.name == "Epic") {
log.debug "testing"
List <ChangeItemBean> changeItems
changeItems = changeHistoryManager.getChangeItemsForField(issue, "Link")
def time = changeItems.findAll{it.getToString()?.contains("is a child of")}?.collect{it.getCreated()}.last()
log.debug(time)
PPMTSD.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(PPMTSD), time),changeHolder)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.