Forums

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

Jira Insight post function : update object attribute.

D X September 12, 2018

Hi all,

 

I have a problem when updating object attribute from a post function jira issue.

here is the situation :

Insight : objectType :

Name                  Type                Value

objA                    objTypA
objA2                  objTypA
objA3                  objTypA
objB                    objTypB
objB2                  objTypB
objC                    objTypC
...

 

After closing a ticket, I assign a value (like objA, objB...) on a Insight Custom Field on next issue. This value is based on another custom field value (like 'objTypA'...).

Depending of this last value, the Insight object custom field is fill with a random Insight Object from "objectType", WHEN Value is not empty.

The problem is when I try to update "Value" Attribute from "objectType" with a value ("1" by instance).

For this, I use this script : https://documentation.riada.se/display/ICV54/Update+object+attribute. But the problem is when script has run, it updates all attributes from "objectType" fill on custom field (i.e if Insight Custom Field has "objA3" assigned, all Objects objA, objA2 and objA3 are updated with value "1", because the other custom field is "objTypA").

but when I update script with "insightObjects[0]" instead passing on For statement, the first object is update, even if this is another value filled on Insight Custom Field.

 

How I can force update of the good object in Insight ?

hope to be clear.

Regards,

 

1 answer

1 accepted

0 votes
Answer accepted
Nader Nassif
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 18, 2018

Hi,

You can update your script to be something like : 

import com.atlassian.jira.component.ComponentAccessor;

/* The object facade class */
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade");

/* The reference to the object facade which you can use in your code */
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);

storeObjectAttributeBean(objectFacade.loadObjectBean("ObjectKey").getId());)

 For more information on the groovy syntax : insight-core

You could also use a hidden custom field and set the latest value from your objA3 into and then read it in any postScript and write to any field you wish

 

Best regards,

Nader

D X September 18, 2018

Hi Nader,

yes you're right

thanks to you

Suggest an answer

Log in or Sign up to answer