Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


...

Code Block
Info

Some users want to access SLA Data with scripts for further operations. We don't support it officially, but provide solutions as is.

Solution

Expand
titleGet field calculations
languagejava
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.coresoftlabs.sla_powerbox.field.slametric.SlaCustomFieldModel
import com.coresoftlabs.sla_powerbox.calculate.service.SlaCustomFieldCalculateService

@WithPlugin("com.coresoftlabs.sla_powerbox.sla_powerbox")

@PluginModule
SlaCustomFieldCalculateService slaCustomFieldCalculateService

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def slaCustomField = customFieldManager.getCustomFieldObject("customfield_xxxxx")

SlaCustomFieldModel slaCustomFieldModel = slaCustomFieldCalculateService.getSlaModelUsingDefaultStrategy(issue, slaCustomField)
Long requiredSla = slaCustomFieldModel.getRequiredSla()
Long spentSeconds = slaCustomFieldModel.getSpentSeconds()
if (requiredSla == null || spentSeconds == null) {
return null;
}
Long result = Math.round((spentSeconds.doubleValue() / requiredSla.doubleValue()) * 100)
return result.intValue()
 


Content by Label
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@a5d
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel in ( "developer" , "scripting" ) and type = "page" and space = "SP"
labelsscripting developer

...