The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Behaviours not longer set Assets custom fields

D X
January 29, 2024

Hi all,

this week end, we proceed to some jira upgrade (V 9.12.2). so from this time a major Behaviours script is no longer working.
After some search, it seems the Insight (now Assets) custom fields are not populated correctly

I rework the initial script, and test Asset creation (works fine), but the setFormField never display the value needed

 

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeAttributeFacade
import com.riadalabs.jira.plugins.insight.services.model.ObjectBean
import groovy.transform.BaseScript

@WithPlugin('com.riadalabs.jira.plugins.insight')
@BaseScript FieldBehaviours fieldBehaviours
@PluginModule ObjectFacade objectFacade
@PluginModule ObjectTypeAttributeFacade objectTypeAttributeFacade

def FTestValue = getFieldById("customfield_xxxxx")
def FInsightCf = getFieldById("customfield_yyyyy")
def cfvalue = Assets.getById(aaaaa)

log.warn("testvalue is:" + cfvalue.getLabel())
FTestValue.setFormValue(cfvalue.getObjectKey())
FInsightCf.setFormValue(cfvalue)

 

at this point, the FtestValue (simple text customfield) show correctly the Asset Key of seelcted object

 

but the FInsightCf.setFormValue(cfvalue) didin't set the custom field
I tried in several ways such as setFormValue(["TheKey"]) setFormValue("TheKey") setFormValue(TheId), setFormValue(Assets.getByKey('AAA-1').. . but nothing happened.

 

checking this page https://docs.adaptavist.com/sr4js/latest/hapi/work-with-assets-insight but found nothing interesting in my case

 

Thank you

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Manne Kjærby - ProProces
Atlassian Partner
January 29, 2024

Hi DX.

 

Working with Behaviours and Assets fields is abit funky, and I haven't worked with it since it was called insight, however I have some experience

Have you tried to set it the same way as FTestValue?
FInsightCf.setFormValue(cfvalue.getObjectKey())

Maybe thats what you mean by: setFormValue("TheKey").. However thats how I usually have set the asset/insight field on a behaviour.

 

Can you see anything in the logs?

D X
January 29, 2024

Dear @Manne Kjærby - ProProces 

thank you for your quick answer, but the test value retrieve the correct Asset Key.

 

but for the InsightCF, whatever I use as code to (even your code) not working :(

 

regards

Manne Kjærby - ProProces
Atlassian Partner
January 29, 2024

Hi D X.

Hmm. I believe you're best option is to reach out to adaptavist as scriptrunner is their product - Maybe they are aware of what have changed? 

Have you tried to hardcode an asset into like FInsightCf.setFormValue("ABS-123") ?

I hope you figure it out.

D X
January 29, 2024

Yes, that the first thing I'm doing (hardcoded) but having nothing

 

regards

TAGS
AUG Leaders

Atlassian Community Events