Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic class loading from apps API

Alexander Raymukanov
Contributor
May 18, 2021

Good day,

I try to prepare groovy script to realize logic before export with Better Excel Exporter.

I need to read value from project custom field (projectrak/profields app) and with scriptrunner I make it this way

import com.deiser.jira.profields.api.field.FieldService
import com.deiser.jira.profields.api.field.list.ListField
import com.deiser.jira.profields.api.value.ValueService

@WithPlugin("com.deiser.jira.profields")

def valueService = ComponentAccessor.getOSGiComponentInstanceOfType(ValueService.class)
def fieldService = ComponentAccessor.getOSGiComponentInstanceOfType(FieldService.class)

ListField field = fieldService.get("Included in the week reports").get(0)
def fieldValue = valueService.getValue(project, field)

But groovy in Better Excel Exporter dont have this features of scriptrunner and I try to make it with dynamic class loading this way

in class constructor I make loading of classes

valueServiceClass=ComponentAccessor.pluginAccessor.classLoader.loadClass("com.deiser.jira.profields.api.field.FieldService")
fieldServiceClass=ComponentAccessor.pluginAccessor.classLoader.loadClass("com.deiser.jira.profields.api.value.ValueService")
listFieldClass=ComponentAccessor.pluginAccessor.classLoader.loadClass("com.deiser.jira.profields.api.field.list.ListField")
valueService=ComponentAccessor.getOSGiComponentInstanceOfType(valueServiceClass) fieldService=ComponentAccessor.getOSGiComponentInstanceOfType(fieldServiceClass) listField=ComponentAccessor.getOSGiComponentInstanceOfType(listFieldClass)

But with log I see that listFieldClass= interface com.deiser.jira.profields.api.field.list.ListField

and listField=null (looks that is not right)
and then in function I want to make read of field value like this

def field = this.listField.newInstance()
field = this.fieldService.get("Included in the week reports").get(0)
def fieldValue = this.valueService.getValue(project, field)

But script doesn't go through line with def field = this.listField.newInstance()

 

In logs I don't see exact groovy error message, only messages of fail render from Better Excel Export app. And I don't have experience yet with dynamic class loading so maybe I just failed with code logic

 

1 answer

0 votes
Fede Baronti -Deiser-
Community Champion
May 19, 2021

Hi @Alexander Raymukanov ,

I'm Fede Baronti from DEISER. Thanks for submitting your question in the community. 

Since you've also reported a support request we'll communicate with you through that channel. 

Thanks again and best regards,

Fede.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events