Hi
I've been trying to get worklog attributes from worklogs that are being entered. I want to find out if the worklog has the attribute _overtime_ and if so which value it has. I have a groovy script that is being called when the event worklogadd is executed.
The worklog element simply does not contain any attributes that have been created in Tempo so I have tried several things. I've tried to contact the Tempo plugin by using Rest:
String JIRA_API_URL = "http://OUR_SERVER/rest/tempo-timesheets/3/worklogs/" + worklog.id
HTTPBuilder jira = new HTTPBuilder(JIRA_API_URL)
jira.client.addRequestInterceptor(new HttpRequestInterceptor() {
void process(HttpRequest httpRequest, HttpContext httpContext) {
httpRequest.addHeader('Authorization', 'Basic ' + 'ProgramUser:admin'.bytes.encodeBase64().toString())
}
})
def tempoWorklog = jira.get(path: JIRA_API_URL )
log.warn("\nLogFlexTime worklogproperties issue " + tempoWorklog + "\n" + worklog.id)
This does give a result, but the object that is returned contains an empty workAttributeValues list. I have no idea why the workAttributeValues is empty. All the other values are there in the worklog object that is returned.
I've also tried the non rest way decribed here:
https://scriptrunner.adaptavist.com/4.3.0/jira/working-with-tempo.html
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.tempoplugin.worklog.attribute.WorklogAttributeService
@WithPlugin("is.origo.jira.tempo-plugin")
@PluginModule
WorklogAttributeService worklogAttributeService
boolean isOvertime = worklogAttributeService.getWorklogAttributes(11014).containsKey("_Overtime_")
log.warn("\nLogFlexTime isOvertime " + isOvertime)
This fails with the following error:
LogFlexTime.groovy: 24: unable to resolve class com.tempoplugin.worklog.attribute.WorklogAttributeService
@ line 24, column 1.
import com.tempoplugin.worklog.attribute.WorklogAttributeService
^
1 error
So I'm a bit lost here. I really need to figure out if the time logged on an issue is overtime or not. Anybody got any tips on this one?