How can we obtain the value of an attribiute of an insight object in Jira DC?

How can we obtain the value of an attribiute of an insight object? I need to read an atribute and if it is a certain value, to continue with the sync

1 Like

Hi @gabern,

To accomplish this, you have to set up a custom field of type “Insight Object/s” and add it to your issue view as seen below:

The attributes you read in your script will be based on the Insight object you have selected in your issue’s custom field.

This script below retrieves the value of a custom field called InsightField from an Insight object. It then extracts the Name attribute from this field, removes any square brackets ([]), and compares the resulting string with "JPTest". If the value doesn’t match "JPTest", the script stops further execution (via return).

def insightObject = issue.customFields."InsightField"?.value

// Check and read the specific attribute value
def attributeValue = insightObject.Name.toString().replaceAll('[\\[\\]]', '') // Replace 'Name' with your attribute

// Continue with sync if the attribute value matches a certain condition 
if (attributeValue.toString() != "JPTest") {
    return
}

You can use debug.error(attributeValue) to check the attribute’s value, for example:

insightObject.Created:


insightObject.Name:

1 Like

Hi @gabern,

Were you able to give this a try? Let me know if it worked for you :slight_smile: