Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Teams
, (opens new window)

Power Scripts for Jira Cloud
Results will update as you type.
  • Get started
  • Configuration guides
  • Integration guides
  • Feature guides
  • Advanced features
  • Migration resources
  • Simple Issue Language
  • Tutorials and recipes
    • Power Scripts recipes
      • Add a group as participants in Jira Service Desk
      • Add an internal comment to Jira Service Desk request
      • Add participants automatically to new Jira Service Desk requests
      • Adjust an estimate according to assignee
      • Assign an issue while maintaining the user load
      • Assign issues automatically based on workload
      • Assign issues to the previous assignee
      • Assign users based on a decision table using SIL™
      • Automatically move unresolved issues to next sprint and update story points
      • Automatically update the custom field ID and/or name in filters
      • Calculate the due date based on custom field values
      • Copy a custom field value to another field when changed
      • Copy data from the parent issue
      • Copy the reporter and watchers on duplicate issues
      • Copy watchers to sub-tasks
      • Create a sub-task automatically based on custom field selection
      • Create an issue score custom field
      • Create story subtasks and close them when story is closed
      • Filter by project and issue type
      • Format a number as currency scripted field
      • Get the time spent by an issue in certain statuses
      • Insight REST API
      • Last comment from role scripted field
      • Last comment scripted field
      • Last modified by scripted field
      • Parent issue status scripted field
      • Perform searches with LDAP
      • Prepopulate fields during a transition
      • Reopen issues after a date or time period (boomerang)
      • Reschedule issues
      • Reset a field
      • See and search on the last person to modify an issue
      • Set approver in Jira Service Desk
      • Sum up story points for issues in an Epic
      • Synchronize comments between projects
      • Time of last transition
      • Track completion progress
      • Transition past due issues
      • WSJF scripted field
      • Syncing custom field options with external data (Database)
      • Large bulk operations - memory optimization
      • Bi-direction sync with external system
      • Priority score scripted field
    • Recipes by script type
    • Recipes by use case category
    • Utility scripts
    • Rich text formatting guide for Jira Cloud
    • How-to guides
  • Jira Product Discovery support
  • Release notes
  • Help and support
    You‘re viewing this with anonymous access, so some content might be blocked.
    /
    Insight REST API
    Updated Aug 12

    Insight REST API

    Insight Inclusion Script

    The following code is a library of functions that works with the Insight (Jira Assets) REST API using manual HTTP requests.

    struct objectType { number id; string name; number type; string created; string updated; number parentObjectTypeId; number objectSchemeid; boolean inherited; } struct referenceObj { number id; string label; string objectKey; objectType objectType; string created; string updated; } struct attributeValue { string value; string displayValue; referenceObj referencedObject; } struct attribute { number id; number objectTypeAttributeId; attributeValue[] objectAttributeValues; number objectId; number position; } struct objectEntry { number id; string label; string name; string objectKey; objectType objectType; attribute[] attributes; } struct defaultType { number id; string name; } struct objectTypeAttribute { number id; string name; string label; number type; defaultType defaultType; boolean editable; boolean system; boolean sortable; boolean summable; number minimumCardinality; number maximumCardinality; boolean removable; boolean hidden; boolean includeChildObjectTypes; boolean uniqueAttribute; string options; number position; } struct insightQueryResult { objectEntry[] objectEntries; objectTypeAttribute[] objectTypeAttributes; } /* * Retrieves the Insight object key of a Jira issue custom field. * @param fieldValue (string) The value of a custom field. * @return (string) The object key of the insight object. Example: ABC-123 */ function getCustomFieldInsightKey(string fieldValue) { return matchText(fieldValue, "(?<=\\().+?(?=\\))"); } /** * Runs a query against a specified insight schema to gather object(s) using the * IQL query language. See https://bit.ly/2OI5QVt for more info about IQL. * @param schemeId (string) The id of the insight schema to query. Example: "2" * @param iqlQuery (string) The IQL query string to return the desired objects. Example: 'Key in ("ABC-1", "ABC-2")' * @param username (string) Username of user of Insight schema. * @param password (string) Password that corresponds to the 'username' parameter. * @return insightQueryResult representation of query result. */ function getInsightObject(string schemeId, string iqlQuery, string username, string password) { string insightURL = getJIRABaseUrl()+"/rest/insight/1.0/iql/objects"; HttpRequest request; request.headers += httpBasicAuthHeader(username, password); request.parameters += httpCreateParameter("objectSchemaId", schemeId); request.parameters += httpCreateParameter("iql", iqlQuery); insightQueryResult result = httpGet(insightURL, request); return result; } /* * Retrieves the value of an attribute based on the provided attribute name. * @param obj (insightQueryResult) Insight object to retrieve value from * @param attributeName (string) The name of the attribute to retrieve. * @return string representation of attribute value if found. Otherwise, null if attribute is not found. */ function getInsightObjectAttribute(insightQueryResult obj, string attributeName) { string[] result; if(isNotNull(obj)) { // Determines if an attribute with propvided 'attributeName' exists. // If true, saves the corresponding id of attritute to search for value. number attributeId = 0; for(objectTypeAttribute t in obj.objectTypeAttributes) { if(t.name == attributeName) { attributeId = t.id; break; } } // If attribute exists, finds the corresponding value of the attribute. if(attributeId != 0) { for(objectEntry o in obj.objectEntries) { // Possible multiple objects for(attribute a in o.attributes) { // Possible multiple attribute values if(a.objectTypeAttributeId == attributeId) { for(attributeValue v in a.objectAttributeValues) { result += v.displayValue; break; } } } } } } return result; }

    Need support? Create a request with our support team.

    Copyright © 2005 - 2025 Appfire | All rights reserved.

    {"serverDuration": 17, "requestCorrelationId": "85298e5d5688457dac77a4ab9e135f2a"}