Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

updating insight object(attributes) with scriptrunner

Rasa I'm New Here Dec 01, 2021

Hello,

I am trying to change Insight object attributes values via Scriptrunner. Some of them are taken from Jira issue, some are recalculated according to the rules. It's possible to do POST with a huge JSON, but maybe there is a better way to manipulate the InsightObjectAttribute?

The attributes can be type of text, url, user, select, list of values.
I can find the object, even found how to delete the attribute, but unable to figure out how to update it.

E.g.I use this for deletion of attributes:

def deleteInsightObjectAttribute(def object, def attributeKey){
    if (object != []){
        Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade");
        def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);
        def myAttrValue = objectFacade.loadObjectAttributeBean(object.id, attributeKey).createMutable()
        value = myAttrValue.getObjectAttributeValueBeans()
        value.clear()
        try {
            objectFacade.deleteObjectAttributeBean(myAttrValue.id); 
        } catch (Exception vie){
            log.warn "Could not update object attribute due to validation exception:" + vie.getMessage()
        }
    }else{
        log.error "Insight object not found."
    }
}

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you