We want to get both the SLA total time and remaining time for an issue.
I'm using the following from Adaptavist to attempt to get the remaining time:
https://library.adaptavist.com/entity/copy-sla-information-to-a-custom-field
In a Debug script in TEST i have the following script:
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.web.bean.PagerFilter
import org.apache.log4j.Level
import org.apache.log4j.Logger
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.servicedesk.api.sla.info.SlaInformationService
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@WithPlugin("com.atlassian.servicedesk")
@PluginModule SlaInformationService slaInformationService
def searchService = ComponentAccessor.getComponent(SearchService.class)
def issueManager = ComponentAccessor.getIssueManager()
def LogEntry = Logger.getLogger("Jira Log")
LogEntry.setLevel(Level.INFO)
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def jqlSearch = "Key=LOGS-36590"
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch)
if (parseResult.isValid()) {
def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
def issues = searchResult.results.collect {issueManager.getIssueObject(it.id)}
issues.each { issue ->
LogEntry.info("ISSUE ID": + issue.id)
// https://library.adaptavist.com/entity/copy-sla-information-to-a-custom-field
// SLA field name
final slaName = 'Open To Close'
// Gets the SLA information querying SLA service for the current issue
// https://docs.atlassian.com/jira-servicedesk/3.8.4/com/atlassian/servicedesk/api/sla/info/SlaInformationQuery.Builder.html
def query = slaInformationService.newInfoQueryBuilder()
.issue(issue.id)
.build()
//https://docs.atlassian.com/jira-servicedesk/3.8.4/com/atlassian/servicedesk/api/sla/info/SlaInformationService.html
def slaFormatter = slaInformationService.durationFormatter
def sla = SlaInformationService.getInfo(user, query).results.find { it.name == slaName }
}
} else {
LogEntry.error("Invalid JQL :" + jqlSearch)
}
LogEntry.info("Completed")
I get the following in the log Output
INFO [Jira Log]: {ISSUE ID=449689}
ERROR [common.UserScriptEndpoint]: *************************************************************************************
ERROR [common.UserScriptEndpoint]: Script console script failed: groovy.lang.MissingMethodException: No signature of method: static com.atlassian.servicedesk.api.sla.info.SlaInformationService.getInfo() is applicable for argument types: (com.atlassian.jira.user.DelegatingApplicationUser, com.atlassian.servicedesk.internal.sla.info.SlaInformationQueryImpl) values: [David.Harkins(JIRAUSER20408), com.atlassian.servicedesk.internal.sla.info.SlaInformationQueryImpl@3df9c36]
Possible solutions: notify()
at IssueSLA_Details$_run_closure2.doCall(IssueSLA_Details.groovy:41)
at IssueSLA_Details.run(IssueSLA_Details.groovy:26)
I kind of expected this to work first time, but no such luck.
Can anyone provide some pointers in the right direction?
there is a missspelling in Line 41
def sla = SlaInformationService.getInfo(user, query).results.find { it.name == slaName }
try
def sla = slaInformationService.getInfo(user, query).results.find { it.name == slaName }
Thank you so much, though I do feel a little stupid now.
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.