Forums

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

How to update ObjectAttributeValueBean

Dominik Hufnagel July 3, 2023
My code modifies the specific referenceID, but I am not able to update it and can't find a method in class MutableObjectAttributeValue
def objectAttributeBean_definition = objectFacade.loadObjectAttributeBean(id_ServerObject, objectTypeAttributeBean_servVertraulichkeitId) //Type: Attributes$AttributeWithSingleValue
objectAttribute_servVertraulichkeit = objectAttributeBean_definition.createMutable() //Type: MutableObjectAttributeBean
objectAttributeValue_servVertraulichkeit = objectAttributeBean_definition.getObjectAttributeValueBeans() // Type: .Collections$SingletonList
               
objectAttributeValue_servVertraulichkeit.each {
objectAttributeValue_of_servVertraulichkeit ->
                    xyz = objectAttributeValue_of_servVertraulichkeit.createMutable() //Type: MutableObjectAttributeValueBean
xyz.setReferencedObjectBeanId(actualAttributeValue_anwVertraulichkeit)
 }
which method do I have to use to save / store or update the modified value?

1 answer

0 votes
Dominik Hufnagel July 3, 2023

Need some help, because I don't know how to update or store the modified MutableObjectAttributeValueBean

I am able to set a new ReferecedObjectId, but don't know how to store the value. At the moment it is just an assignment, which will not be seen in Object-Attribute within the Jira Insight GUI

 

I had a look in insight plugin 10.4.5 api documentation, but could not find a method for the either MutableObjectAttributeValue or ObjectAttributeValueBean to update/store the value

Doc-Link:ObjectAttributeValueBean (Insight Plugin 10.4.5 API) (atlassian.com)

Nikolai Ruban November 12, 2024

in case anyone is wondering how Insight object can be created, here is the example.

you can find more examples by searching for createMutableObjectBean, createObjectAttributeBeanForObject or some other "bean" names. There are plenty of script examples.

import com.atlassian.jira.component.ComponentAccessor;

class Constants {
static final INSIGHT_REC_TYPEID = 1006
static final INSIGHT_FIELD_NAME = 12849
static final INSIGHT_FIELD_ISSUEID = 12850
static final INSIGHT_FIELD_SDICKET = 12851
}
import static Constants.*

Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade");
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);
Class objectTypeFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeFacade");
def objectTypeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectTypeFacadeClass);
Class objectTypeAttributeFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeAttributeFacade");
def objectTypeAttributeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectTypeAttributeFacadeClass);
Class objectAttributeBeanFactoryClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.services.model.factory.ObjectAttributeBeanFactory");
def objectAttributeBeanFactory = ComponentAccessor.getOSGiComponentInstanceOfType(objectAttributeBeanFactoryClass);

def IssueIDName = "Request " + issue.getKey();

// Create Escalation Object
def objectTypeCustomer = objectTypeFacade.loadObjectTypeBean(INSIGHT_REC_TYPEID);

/* Create a new unsaved object bean */
def newObjectBean = objectTypeCustomer.createMutableObjectBean();
/* Set up the attribute list */
def objectAttributeBeans = new ArrayList();

// insight record Name
def nameObjectTypeAttributeBean = objectTypeAttributeFacade.loadObjectTypeAttributeBean(INSIGHT_FIELD_NAME);
objectAttributeBeans.add(objectAttributeBeanFactory.createObjectAttributeBeanForObject(newObjectBean, nameObjectTypeAttributeBean, IssueIDName));

// SD Ticket - service desk issue id of ticket being escalated
def sdTicketObjectTypeAttributeBean = objectTypeAttributeFacade.loadObjectTypeAttributeBean(INSIGHT_FIELD_SDICKET);
objectAttributeBeans.add(objectAttributeBeanFactory.createObjectAttributeBeanForObject(newObjectBean, sdTicketObjectTypeAttributeBean, issue.getKey()));

/* Set all object attributes to the object */
newObjectBean.setObjectAttributeBeans(objectAttributeBeans);

/* Store the object into Insight. The new ObjectBean will be updated with an unique ID */
try {
newObjectBean = objectFacade.storeObjectBean(newObjectBean);
// log.info("newObjectBean: " + newObjectBean);
} catch (Exception vie) {
log.info("Could not create issue due to validation exception:" + vie.getMessage());
}

 

see also https://confluence.atlassian.com/servicemanagementserver/groovy-script-examples-1384449857.html

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events