Unable to resolve class DefaultIssueChangeHolder

Sanjay Ray
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 22, 2024

I am running the below script in the Script listener

 

// Get the issue that triggered the event
def issue = event.issue

// Check if the issue type is 'Epic'
if (issue.issueType.name == "Epic") {
// Lookup linked issues of type 'Olympus Idea'
def linkedIssues = ComponentAccessor.issueManager.getIssueObjects(issue.get("Related Idea Ticket")?.id, issue)
.findAll { it.issueType.name == "Olympus Idea" }

// Lookup Epics linked to the 'Olympus Idea' issues that are not Canceled
def epicIssues = linkedIssues.collectMany { idea ->
ComponentAccessor.issueManager.getIssueObjects(idea.get("Related Idea Ticket")?.id, idea)
.findAll { it.issueType.name == "Epic" && it.status.name != "Canceled" }
}

// Calculate the sum of 'Calculated Story Points', 'Completed work to date', and 'Story Points' for the Epic issues
def sumCalculatedStoryPoints = epicIssues.sum { it.get("Calculated Story Points") as Double ?: 0.0 }
def sumCompletedWorkToDate = epicIssues.sum { it.get("Completed work to date") as Double ?: 0.0 }
def sumStoryPoints = epicIssues.sum { it.get("Story Points") as Double ?: 0.0 }

// Update the 'Calculated Story Points', 'Completed work to date', and 'Story Points' fields of the Epic
def changeHolder = new DefaultIssueChangeHolder()
issue.setCustomFieldValue(issue.getCustomFieldObjectsByName("Calculated Story Points").first(), sumCalculatedStoryPoints)
issue.setCustomFieldValue(issue.getCustomFieldObjectsByName("Completed work to date").first(), sumCompletedWorkToDate)
issue.setCustomFieldValue(issue.getCustomFieldObjectsByName("Story Points").first(), sumStoryPoints)

// Save the Epic issue
ComponentAccessor.issueManager.updateIssue(event.user, issue, EventDispatchOption.ISSUE_UPDATED, false)
}
but the execution is failing with the below log. Please suggest what to do.

2024-04-22 10:46:42.635 ERROR - startup failed:
Script1.groovy: 22: unable to resolve class DefaultIssueChangeHolder
 @ line 22, column 24.
       def changeHolder = new DefaultIssueChangeHolder()
                          ^

1 error

2024-04-22 10:46:42.636 ERROR - Class: com.adaptavist.sr.cloud.events.WebhookExecution, Config: null

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events