I write script for Automation in Asset. Script i save in Script Editor ScriptRunner.
But today i red about HAPI and try use it in my realization, but this don't work. I see error about "No such property: Assets for class", i try import
You don't need to import any of the HAPI classes anywhere within the whole Scriptrunner functionality. Including script editor as you can see here:
The only time an explicit import is useful will be if you want to edit code outside of scriptrunner (like an IDE such as intellij). Then importing will help with some autocomplete.
Note that autocomplete will not work in Intellij for injected methods. See https://productsupport.adaptavist.com/browse/SRJIRA-6649 for more details
Yes, when u write script it's correct. But when you use this script to automation Assets in “then” you get the errors that I described
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You cannot use HAPI or anything from the scriptrunner framework in either the Assets Console or Assets automation.
If you want to use scriptrunner script with Assets, then create a Script Listener in scriptrunner and use the appropriate InsightObjectXXX Event.
If you want to use native Asset script environment, then you have to use pure Assets api
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This generalisation is not true, Scriptrunner's HAPI does work with Assests. See https://docs.adaptavist.com/sr4js/latest/hapi/work-with-assets-insight for the things HAPI does support with Assets.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You cannot use HAPI or anything from the scriptrunner framework in either the Assets Console or Assets automation
I think I could have been clearer about that line.
But in Asset Script Console (<baseurl>/secure/admin/InsightPluginInitScriptConsole.jspa) HAPI, and other classes provided by scriptrunner (like PluginModule and WithPlugin) are not available.
The same is true if you create a groovy script that you want to link to the native Assets Automation module (under Configure Object Schema):
The user was trying to use a script created with HAPI in the script editor and point to it from the Assets Automation module.
The groovy implementation built into the Assets plugin actually uses a pretty old version of groovy. 2.4.15 from what I can tell:
As opposed to Scriptrunner:
Asset Groovy framework scripts won't have the ability to import classes stored in the script root with simple import statements.
You have to use the Groovy class loader and load the groovy file (which causes re-compilation with every execution).
So I'm moving away from that Asset's groovy implementation and automation feature in favor of Scriptrunner listeners. Much more powerful and efficient.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you @Peter-Dave Sheehan
Then maybe you know why when I use Insight Automation when getting object.getClass() I get type LegacyObjectBean instead of ObjectBean?
I was able to write changing the attribute values through ScriptRunner Listeners, but I’m also interested in how to implement it through “then” in Insight Automation, but because I have all the LegacyObjectBeans, I can’t update the values.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can convert a LegacyObjectBean into a MutableObjectBean like this:
import com.atlassian.jira.component.ComponentAccessor
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade
import com.riadalabs.jira.plugins.insight.services.model.MutableObjectBean
ObjectFacade objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ObjectFacade)
def object = objectFacade.loadObjectBean('XXX-890')
def mutableObject = MutableObjectBean.create(object)
mutableObject.getClass()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have my code for example here, i already tried in last each getting from foundObject MutableObjectBean, but still the same createObjectAttributeBeanForObject() doesn't work, because first parameter should be with ObjectBean type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is my first attempt at creating/updating objects and there are some things I still don't fully understand. HAPI is much friendlier in terms of automation :)
But unfortunately, in my own plugin later I will need to figure out how to do all this without HAPI...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Alexandra Kolesova ,
Could you show a few screenshots of what you are trying to achieve and the error you are getting please?
Kind regards,
Bobby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi there,
I have run into into the same issue. Did you find a solution how to use the HAPI Code in the Scripts for Asset Automation?
Cheers,
Leonie
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi there!
HAPI is only included from Scriptrunner version 7.11.0+. Might want't to check your version installed?
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have HAPI in my version, but it not work when i use script in Automation Assets
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.