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?
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.")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.