This seems like a very basic, fundamental question and I've googled and looked through online doc but am having no luck with this so far.
I'm writing a groovy script using some classes that access the Insight API written by Peter-Dave Sheehan (which are quite useful, thank you Peter-Dave). What I need is a list of keys for the object types populated in a given schema.
I'm fairly new to Insight so my vocabulary may not be exactly correct so I'll try to describe it. Let's say I have an Insight Object Schema called "Divisions" that defines an Object Type named "Department", each with an attribute named "Office". We then create 3 Departments and fill out their Office attribute. The hierarchy might look like this (please forgive my primitive formatting since this text editor tool is limited):
Example Object Schema
Object Schema: Divisions
-----> Object Type: Department
------> Attribute: Office
So, the Divisions object schema contains an object type named Department with an attribute called Office.
Example Object Types
Object Schema: Divisions
-----> Facilities
------> Office 123
-----> Marketing
------> Office 561
-----> Human Resources
------> Office 35
So, there are 3 Departments (Facilities, Marketing, Human Resources), each with an associated office attribute (Office 123, Office 561, Office35).
I need an IQL/AQL statement that returns a list of all the Department keys that have been added to the Divisions Object Schema (I ultimately be using the result to create JSON for a REST Endpoint) but I can't figure out how.
Later I will need to grab the attribute values for each of these Departments as well.
Thanks in advance!
An IQL to return all the Department objects should be quite simple, it's just "objectType = Department".
Running this either in the Assets/Insight Search screen, or in the InsightUtils.findObjects() method should return 3 objects.
E.g.
import com.qad.common.jira.utils.InsightUtils
def iql = 'objectType = Department'
def departmentObjects = InsightUtils.findObjects(iql)
def departmentKeys = departmentObjects.collect{it.objectKey}
def departmentOffices = departmentObjects.collect{deptObject ->
InsightUtils.getAttributeValueFromDotNotation(deptObject, 'Office', false)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.