Hi there,
after two days of googling and investigations and so many failed attempts I am asking the most wisdom community in the world.
The usacase is simple:
I have an issue type "Objective" with Scripted field "Objective points"
This "Objective points" should sum-up all "Feature points" from all epics linked thru issue link type 10308.
Here is my script inspired by Adaptavist library:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
final issueTypeName = "Objective" // The issue type for which we want the scripted field to be displayed
final linkedIssueType = "Epic" // The linked issues with that issue type will used
final customFieldName = "Feature Points" // The values of that custom field - of type number - we want to sum up
int issueLinkType = 10308
if (issue.issueType.name != issueTypeName) {
return null
}
def linkedIssues = ComponentAccessor.issueLinkManager.getOutwardLinks(issue.id).findAll { it.destinationObject.issueType.name == linkedIssueType }
if (!linkedIssues) {
return null
}
def customField = ComponentAccessor.customFieldManager.getCustomFieldObjects(linkedIssues.first().destinationObject).findByName(customFieldName)
if (!customField) {
log.debug "Custom field is not configured for that context"
return null
}
linkedIssues*.destinationObject.sum { Issue it -> it.getCustomFieldValue(customField) ?: 0 }
The problem is, that this will sum-up all Epics, not only those linked thru 10308.
I did various experiments with getIssueLinks(issueLinkType) or even with getting all outwardLinks as list and finding in them via for item in outwardLinks blahblah linkedIssues.add(result) but that failed on summing part which was unable to reach CFs - I do not figure out why.
If you know any elegant way, you help will be appreciated. Probably I am missing something very stupid and I was almost there :-/
Thanks, Tom
Hi @gianpcruz
I am the Product Manager for ScriptRunner for Bitbucket and thank you for using the product.
Here are my answers:
1. Inline scripts are saved in the Bitbucket database.
2. Regarding audit logging we currently have this, which hooks into Bitbucket's native audit logging: https://scriptrunner.adaptavist.com/latest/bitbucket/audit-logging.html
I hope this helps answer your questions regarding the product?
Please let me know if you have any more?
Kind regards,
Robert Giddings,
Product Manager for ScriptRunner for Bitbucket
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.