How do we display message box from Groovy script

JIRA Admins October 22, 2020

Hello,
I have a Groovy script triggered by Insight object attribute editing (The script is run by Insight Automation). This script makes or not some changes to the edited object, depending on the permissions of the person who edited the attribute. I would like to display a popup message to the user if the script made changes. I tried to use import com.onresolve.scriptrunner.runner.util.UserMessageUtil, but no luck. Below is my function which I use to edit attribute. Could you please suggest me some solution?

void updateAttributeInObject(def insightObject, ArrayList<String> oldValue, Integer attributeId){
// Set svc account ass current user
ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(scriptConfig.svcScriptRunner)

// Get Insight Object Facade from plugin accessor
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().
findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade")
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass)

// Get Insight Object Attribute Facade from plugin accessor
Class objectTypeAttributeFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().
findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeAttributeFacade")
def objectTypeAttributeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectTypeAttributeFacadeClass)

// Get the factory that creates Insight Attributes
Class objectAttributeBeanFactoryClass = ComponentAccessor.getPluginAccessor().getClassLoader().
findClass("com.riadalabs.jira.plugins.insight.services.model.factory.ObjectAttributeBeanFactory")
def objectAttributeBeanFactory = ComponentAccessor.getOSGiComponentInstanceOfType(objectAttributeBeanFactoryClass)

// This is the user object type attribute and the one we want to modify
def objectTypeAttributeBean = objectTypeAttributeFacade.loadObjectTypeAttributeBean(attributeId)
// Create the new attribute bean based on the value
def newObjectAttributeBean = objectAttributeBeanFactory.createObjectAttributeBeanForObject(insightObject, objectTypeAttributeBean, *oldValue)
// Load the attribute bean
def objectAttributeBean = objectFacade.loadObjectAttributeBean(insightObject.getId(), objectTypeAttributeBean.getId())
// Reuse the old id for the new attribute
newObjectAttributeBean.setId(objectAttributeBean.getId())
// Store the object attribute into Insight.
objectAttributeBean = objectFacade.storeObjectAttributeBean(newObjectAttributeBean)
}

 

Regards
Tomasz

1 answer

0 votes
ss January 31, 2021

Hi, @JIRA Admins , Tomasz,

 

Were you able to find any solution to your problem. 

I am also having a same issue. I need to pop-up a message box from a listener code. And just like you mentioned import com.onresolve.scriptrunner.runner.util.UserMessageUtil does not work. And its because it has a bug which adaptavist has confirmed and registered it. Unfortunately it's context works only in issue based events.

My code is running for ProjectRoleUpdatedEvent listener.

Can you share if you were able to found any solution? it will be a great help.

regards

Suggest an answer

Log in or Sign up to answer