Forums

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

updating insight object(attributes) with scriptrunner

Rasa
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 1, 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