JIRA Server 7.3.7 and SR 5.0.14
I have follow code which save the status for work log in Tempo Work Attributes
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.tempoplugin.core.workattribute.api.WorkAttributeService
import is.origo.jira.plugin.common.TempoWorklogManager
import com.tempoplugin.core.datetime.api.TempoDateTime
import org.apache.log4j.Category
@WithPlugin("is.origo.jira.tempo-plugin")
@PluginModule
TempoWorklogManager tempoWorklogManager
@PluginModule
WorkAttributeService workAttributeService
def worklog = event.getWorklog()
def issue = event.getIssue()
//def currentUser = ComponentAccessor.getJiraAuthenticationContext().getUser()
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def changeHistoryItems = changeHistoryManager.getAllChangeItems(issue).reverse()
def LastStatus = changeHistoryItems.find {
it.field == "status"
}
def lastStatusName = LastStatus.toValues.values()
def Category log = Category.getInstance("com.onresolve.jira.groovy.InstallListener")
log.setLevel(org.apache.log4j.Level.DEBUG)
def triageType = workAttributeService.getWorkAttributeTypes().returnedValue.find{it.name == "_WorkType_"}
tempoWorklogManager.updateWorklogAttributes(
worklog.getId().toString(),
["_Status_": lastStatusName]
)
But there is undefined method:
tempoWorklogManager.updateWorklogAttributes(
worklog.getId().toString(),
["_Status_": lastStatusName]
)
Could you help me to find documentation about using methods of components, or tell me where is the error
import com.tempoplugin.core.workattribute.api.WorkAttributeService
import is.origo.jira.plugin.common.TempoWorklogManager
Thank you
Find a solution for creating
def workAttrBuilder = new WorkAttributeValue.Builder(
worklog.getId(),
attribute
).value(lastStatusName.toString())
def workAttr = workAttrBuilder.build();
workAttributeValueService.createWorkAttributeValuesByWorklog(worklog.getId() , [workAttr])
But can't get it work with updating
def workAttrUpdBuilder = new WorkAttributeValue.Builder(atributeValue).value(lastStatusName.toString())
WorkAttributeValue workUpdAttr = workAttrUpdBuilder.build()
def res = workAttributeValueService.updateWorkAttributeValue(workUpdAttr)
Could you help me with it?
My point is that the method
tempoWorklogManager.updateWorklogAttributes(
worklog.getId().toString(),
["_Status_": lastStatusName]
)
Doesn't exist in the class TempoWorklogManager
So my task is to update or create tempo worklog attributes
I find the WorklogAtributeValueService class but i can't figure out how it works
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can see that this script produces a static type checking error in the inline editor, but have you actually tried running it? What errors do you get? Sometimes the inline editor will tell you the method can't be found, but the script will still work. Also, have you tried explicitly defining the IssueEvent?
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.tempoplugin.core.workattribute.api.WorkAttributeService
import is.origo.jira.plugin.common.TempoWorklogManager
import com.tempoplugin.core.datetime.api.TempoDateTime
import org.apache.log4j.Category
import com.atlassian.jira.event.issue.IssueEvent
@WithPlugin("is.origo.jira.tempo-plugin")
@PluginModule
TempoWorklogManager tempoWorklogManager
@PluginModule
WorkAttributeService workAttributeService
def event = event as IssueEvent
def worklog = event.getWorklog()
def issue = event.getIssue()
//def currentUser = ComponentAccessor.getJiraAuthenticationContext().getUser()
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def changeHistoryItems = changeHistoryManager.getAllChangeItems(issue).reverse()
def LastStatus = changeHistoryItems.find {
it.field == "status"
}
def lastStatusName = LastStatus.toValues.values()
def Category log = Category.getInstance("com.onresolve.jira.groovy.InstallListener")
log.setLevel(org.apache.log4j.Level.DEBUG)
def triageType = workAttributeService.getWorkAttributeTypes().returnedValue.find{it.name == "_WorkType_"}
tempoWorklogManager.updateWorklogAttributes(
worklog.getId().toString(),
["_Status_": lastStatusName]
)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.