/** This example script console script shows how you can update the time spent value for a worklog on an issue.* "All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner* license shall be granted a non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed or* amended and must be included in any circumstances where the code snippet is shared by You or a third party." */// Specify the issue to set the worklog ondefissueKey="<IssueKeyHere>"// Specify the ID of the workflog on the issue to updatedefworklogID="<WorklogIDHere>"// Specify the time to be set updated on the worklog e.g 24m for 24 minutes or 2h for 2 hoursdeftimeSpentValue="<timeSpentValueHere>"// Execute the rest call to updated the worklog on the issue// Note you can see details of other paramaters that can be confgured when updating the workflog in the API page at https://developer.atlassian.com/cloud/jira/platform/rest/v3/?utm_source=%2Fcloud%2Fjira%2Fplatform%2Frest%2F&utm_medium=302#api-api-3-issue-issueIdOrKey-worklog-id-putdefupdateWorklog=put("/rest/api/3/issue/${issueKey}/worklog/${worklogID}").header('Content-Type','application/json')// Override screen security if the field is not on screen. //Note: This paramater means the script must be run as the ScriptRunner Add On User.queryString("overrideScreenSecurity",Boolean.TRUE).body([// Specify the time to be set updated on the worklog"timeSpent":timeSpentValue]).asString()// Check if the workflog was updated correctlyif(updateWorklog.status>=200&&updateWorklog.status<300){return"Worklog added successfully on the ${issueKey} issue"}else{return"${updateWorklog.status}: ${updateWorklog.body}"}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.