import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.tempoplugin.common.TempoDateTimeFormatter
import com.tempoplugin.core.datetime.api.TempoDate
import com.tempoplugin.worklog.v4.rest.InputWorklogsFactory
import com.tempoplugin.worklog.v4.rest.TimesheetWorklogBean
import com.tempoplugin.worklog.v4.services.WorklogService
@WithPlugin("is.origo.jira.tempo-plugin")
@PluginModule
WorklogService worklogService
@PluginModule
InputWorklogsFactory inputWorklogsFactory
def startDate = TempoDateTimeFormatter.formatTempoDate(TempoDate.now())
def worklogManager = ComponentAccessor.getWorklogManager()
def worklogs = worklogManager.getByIssue(issue)
// Add all fields needed to create a new worklog
def timesheetWorklogBean = new TimesheetWorklogBean.Builder()
.issueIdOrKey(issue.key)
.startDate(startDate)
.workerKey(currentUser.key)
.timeSpentSeconds(28800)
.build()
def inputWorklogs = inputWorklogsFactory.buildForCreate(timesheetWorklogBean)
worklogService.createTempoWorklogs(inputWorklogs)
Hi,
This script is run in automation step. Got error: Work attribute 'Kategoria pracy'(_test1_) is required. This is work attribute in Jira Tempo
What to add to:
def timesheetWorklogBean = new TimesheetWorklogBean.Builder()
.issueIdOrKey(issue.key)
.startDate(startDate)
.workerKey(currentUser.key)
.timeSpentSeconds(28800)
.build()
To make it choose "Brak" in "Kategoria pracy"????
Hi @kkoziol ,
Is Work attribute 'Kategoria pracy'(_test1_) is custom field?
You may help below code :-
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManafer = ComponentAccessor.getIssueManager()
def userManager = ComponentAccessor.getUserManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def userToSet = userManager.getUserByKey("userkey")
def userCf = customFieldManager.getCustomFieldObjectByName("user picker") //custom field name
issue.setCustomFieldValue(userCf, userToSet)
issueManafer.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
Hi @kkoziol ,
Oh! Its Jira Tempo plugin. I'm afraid this is not possible at the moment.
You check from below script runner snippet :-
https://library.adaptavist.com/collection/automate-daily-tempo-tasks-in-jira-with-scriptrunner
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.