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)
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.