Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I search in object comments in Insight (Assets) for Jira Service Management?

Kalin U
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 12, 2022

Hi. I need to find specific objects in Insight (Assets) which contain a specific word in the comments. Is it possible to query the object comments, using IQL?

1 answer

0 votes
Karen Thomas October 26, 2023

Need answer to this, please.

Tom Gustafsson November 3, 2024

It is not possible to do IQL search which would filter objects based on comments.

One can do it using groovy script, for example:

import com.atlassian.jira.component.ComponentAccessor

// Define the comment keyword to search for
def commentKeyword = "test comment"

// Initialize the ObjectFacade class to access comments
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade")
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass)

// Retrieve all comments for the current object using findCommentBeans
def comments = objectFacade.findCommentBeans(object.id as int) // Cast object.id to int if necessary

// Check if any comment contains the target keyword
def hasTargetComment = comments.any { it.getComment().contains(commentKeyword) }

if (hasTargetComment) {
// Log the object ID and name to verify that we are targeting the correct object
log.info("Found object with ID ${object.id} and name '${object.name}' containing the target comment.")
}



 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events