Scriptrunner scripted fields integration with Tempo fails

Performing the same script via the Script Console works but via the Scripted Field it fails to retrieve Tempo data like worklog attributes. Are these maybe not saved yet? How to deal with this?

Listening for the event Work Logged on Issue

def attribute = workAttributeService.getWorkAttributeByKey("_Account_").returnedValue
return workAttributeValueService.getWorkAttributeValueByWorklogAndWorkAttribute(latestWorkLog.id, attribute.id).returnedValue.value

"returnedValue" is empty during a scripted field execution, it works fine via the Script Console.

2 answers

0 votes
Anton Chemlev Community Champion Jan 29, 2018

Hi,

Could you please provide full source code for your listener?

You can perform following steps:

1) Check out this topic https://community.atlassian.com/t5/Jira-questions/How-to-get-value-of-Tempo-Worklog-Attribute/qaq-p/453503

2) Add log.info, log.error etc. to you code in order to get info from logs.

Skipping some code but this should help. Like mentioned, retrieving this via the script console, by taking one of the last worklogs, works but via this listener it's null

 

import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.tempoplugin.core.workattribute.api.WorkAttributeService
import com.tempoplugin.core.workattribute.api.WorkAttributeValueService

@WithPlugin("is.origo.jira.tempo-plugin")

@PluginModule
WorkAttributeService workAttributeService

@PluginModule
WorkAttributeValueService workAttributeValueService


def issue = event.issue
def workLogs = worklogManager.getByIssue(issue)
def latestWorkLog = workLogs.sort {it.id}.last()
def timeSpent = latestWorkLog.getTimeSpent()

def attribute = workAttributeService.getWorkAttributeByKey("_Account_").returnedValue // Account
log.error attribute
def accountValue = workAttributeValueService.getWorkAttributeValueByWorklogAndWorkAttribute(latestWorkLog.id, attribute.id)
log.error("Ret value ==== " + accountValue.returnedValue)

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Thursday in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

415 views 1 13
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot