set worklog by script

Jörg Lang December 12, 2012

Hi there,

I need to set some work log by script and I didn't get it working

My code:

import com.atlassian.jira.issue.worklog.WorklogImpl

cus = componentManager.getJiraAuthenticationContext().getUser()
wli = new WorklogImpl(null, 'JLTA-1', 0, cus.name, "work autolog", Date.parse('dd.MM.yyyy hh:mm', '13.12.2012 10:00'), null, null, 3600)
ComponentManager.instance.worklogManager.create(cus, wli, 0, false)

And I receive following error:

javax.script.ScriptException: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: com.atlassian.jira.issue.worklog.WorklogImpl(null, java.lang.String, java.lang.Integer, java.lang.String, java.lang.String, java.util.Date, null, null, java.lang.Integer)

Please Help me, many thanks.

Jörg

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 12, 2012

This is the signature:

WorklogImpl(WorklogManager worklogManager, Issue issue, Long id, String author, String comment, Date startDate, String groupLevel, Long roleLevelId, Long timeSpent)

So second arg should be an Issue, not a string. did not check further than that...

Jörg Lang December 12, 2012

Hey Jamie,
thanks for pushing me into the right direction.
I have changed my code now to:

import com.atlassian.jira.issue.worklog.WorklogImpl
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.MutableIssue

ComponentManager componentManager = ComponentManager.getInstance()
MutableIssue issue = componentManager.getIssueManager().getIssueObject("JLTA-1")

cus = componentManager.getJiraAuthenticationContext().getUser()
wli = new WorklogImpl(null, issue, 0, cus.name, "work autolog", Date.parse('dd.MM.yyyy hh:mm', '13.12.2012 10:00'), null, null, 3600)
ComponentManager.instance.worklogManager.create(cus, wli, 0, false)

And it works now.
Thanks for Helping.
Jörg

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 12, 2012

You're welcome.

TAGS
AUG Leaders

Atlassian Community Events