Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 21:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi!
Here is an example of changing and storing an attribute bean of an insight object: [Example Groovy script to update Object Type attribute value|https://confluence.atlassian.com/jirakb/example-groovy-script-to-update-object-type-attribute-value-1077910497.html]. I extended that example to store three attribute values. I use it in an automation script. Let's name it 'A' and it is triggered on a Move event.
try{
objectBeansToStore.each{objAttBean ->
objectTypeAttributeBean = objectFacade.storeObjectAttributeBean(objAttBean);
}
objectBeansToDelete.each{
objectAttributeBean = objectFacade.deleteObjectAttributeBean(objAttBean.id);
}
} catch (Exception e){
log.error("Could not update object attribute due to validation exception:" + e.getMessage());
}
The problem is that each store triggers an Insight update object event, three in total. That is a problem since I have automations that are triggered on an Object updated event. And when I move hundreds of objects, the other automations multiply by three.
Is there a way to store any number of attributes and their new values to produce only one update event? I looked through the API to see if there is a function that takes a list of Object attributes to update but cannot find any. I'm sorry if I didn't look hard enough and missed something.
I have Jira 8.13.18 and Insight plugin v 8.9.4.
Thanks for the help!
Cheers,
Marina
First off, did you know that you can suppress events altogether?
Instead of
objectTypeAttributeBean = objectFacade.storeObjectAttributeBean(objAttBean)
//or
objectAttributeBean = objectFacade.deleteObjectAttributeBean(objAttBean.id)
You can do
import static com.riadalabs.jira.plugins.insight.services.events.EventDispatchOption.DO_NOT_DISPATCH
objectTypeAttributeBean = objectFacade.storeObjectAttributeBean(objAttBean, DO_NOT_DISPATCH)
//or
objectAttributeBean = objectFacade.deleteObjectAttributeBean(objAttBean.id, DO_NOT_DISPATCH)
But if you still want to store multiple attribute at once, you can do that by updating the MutableObjectBean with setObjectAttributeBeans() then call the objectFacade.storeObjectBean(mutableObjectBean) method.
The challenge is that when you use setObjectAttributeBeans(), you have to include all the attributes, not just the ones you wish to update.
There might be better ways to do that, but here is a method I created that takes a map of attributename:value and replaces all the attributes for the object that are in the map without impacting the other existing attributes:
Perfect. I had exactly the same problem and your solution has fixed it for me.
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.
Thank you!
In the api version, I was looking at those methods and they were not included. And your utils file is excellent! I will try out the proposed options! You helped a lot!
Cheers,
Marina
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.