I'm trying to get some attributes from an object and save them to different variables, yet I keep getting this error when testing on Insight Script Console:
GroovyInsightException: Cannot invoke method getObjectAttributeValueBeans() on null object'
I add the object key to the "Object Key" field but it still sees it as a null object. Does this have to do with my code or does Insight not recognize the key I have inserted?
Here is the code I am testing:
import groovy.json.*
import groovyx.net.http.ContentType
import com.atlassian.jira.issue.*
import com.atlassian.jira.component.ComponentAccessor
import org.joda.time.format.*
import java.lang.String
import java.text.SimpleDateFormat
import org.apache.log4j.*
//Inicialize object & object attributes
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade"));
def objectTypeAttributeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeAttributeFacade"))
def objectAttributeBeanFactory = ComponentAccessor.getOSGiComponentInstanceOfType(ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.services.model.factory.ObjectAttributeBeanFactory"));
//Load object attributes
def key = objectFacade.loadObjectAttributeBean(object.getId(), 1448).getObjectAttributeValueBeans()[0].getValue(); //The id of the attribute
def name = objectFacade.loadObjectAttributeBean(object.getId(), 1449).getObjectAttributeValueBeans()[0].getValue();
def ti = objectFacade.loadObjectAttributeBean(object.getId(), 1463).getObjectAttributeValueBeans()[0].getValue();
def ta = objectFacade.loadObjectAttributeBean(object.getId(), 1464).getObjectAttributeValueBeans()[0].getValue();
def loc = objectFacade.loadObjectAttributeBean(object.getId(), 3981).getObjectAttributeValueBeans()[0].getValue();
def dinc = objectFacade.loadObjectAttributeBean(object.getId(), 4002).getObjectAttributeValueBeans()[0].getValue();
def dfim = objectFacade.loadObjectAttributeBean(object.getId(), 4003).getObjectAttributeValueBeans()[0].getValue();
def org = objectFacade.loadObjectAttributeBean(object.getId(), 4063).getObjectAttributeValueBeans()[0].getValue();
def notes = objectFacade.loadObjectAttributeBean(object.getId(), 4066).getObjectAttributeValueBeans()[0].getValue();
return key;