I’m trying to create an issue programmatically in a ScriptRunner mail handler.
I managed to create issue, add attachments and set most fields… except a custom Insight field.
Using OptionsManager doesn’t work for the Insight field. So I’m looking at this example:
But Script Editor tells me that it cannot find IQLFacade:
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.IQLFacade
import com.riadalabs.jira.plugins.insight.services.model.ObjectBean
@WithPlugin("com.riadalabs.jira.plugins.insight")
@PluginModule IQLFacade iqlFacade
The facade package exist and this import works:
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.*
But there is no IQLFacade class. Has something been changed since that thread?
Edit:
Calling ComponentAccessor.getPluginAccessor().getClassLoader().findClass() does work on com.riadalabs.jira.plugins.insight.channel.external.api.facade.IQLFacade, the class can be found. How come it doesn’t work with WithPlugin/PluginModule and the import?
Edit 2:
Using reflection I managed to parse a string into an insight object (IQL Name = “[String]”) … however, the issue cannot be created due to WorkflowException. If I do not set the insight custom field then everything is fine. So it doesn’t like the value I set, any ideas why?
Edit 3:
So I need to call ObjectFacade.loadObjectBean(id), where id comes from the object returned by IQLFacade. And then I need to wrap the object bean in a list, and set that to the custom field. Then it works.
So now my remaining question is: Why Script Editor cannot resolve IQLFacade class.