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

Can not set attribute value of type object to nothing/blank

I use groovy scripts to automate insight object.
How do I set an attribute of type object to nothing/blank?

I tried with that code:
import com.atlassian.jira.component.ComponentAccessor;

def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade"));
def objectBean = objectFacade.loadObjectBean(object.getId()).createMutable()
def d = objectFacade.deleteObjectAttributeBean(37)
def f = objectFacade.storeObjectBean(objectBean)

There is no error, but the object attribute is not nothing or deleted

 

Setting the value to "" of the example https://documentation.mindville.com/insight/latest/update-an-object-attribute-33466729.html

produces the error:
2021-01-08 06:05:19,794 [http-nio-8080-exec-12] | Could not update object attribute due to validation exception:ValidationInsightException: Validation errors were found: rlabs-insight-attribute-37: ErrorMessage

{i18nKey='rlabs.insight.i18n.constraint.violation.ObjectAttributeValueBean.MinOne.value', parameters=[], additionalMessage=null}

;

2 answers

1 accepted

0 votes
Answer accepted
Hana Kučerová Community Leader Jan 09, 2021

Hi @Reto Zürcher ,

welcome to the Atlassian Community!

Just to be sure - which version of Insight do you have? Concept with deleteObjectAttributeBean always worked for me.

Are you sure about the number 37? It should be object attribute bean id. When you try to get it using attribute id (please replace 123 with the id of attribute you're trying to delete), do you get the same number? 

Integer attributeId = 123
def objectBean = objectFacade.loadObjectBean(object.getId()).createMutable()
objectAttributeBean = objectFacade.loadObjectAttributeBean(objectBean.getId(), attributeId)
if (!objectAttributeBean) {
// log error
}
objectFacade.deleteObjectAttributeBean(objectAttributeBean.getId())

Also, remove this line:

def f = objectFacade.storeObjectBean(objectBean)

Very fast and helpfull community reply, cool! Thank you very much!

Thanks for the solution!

We had a similar problem. We had an attribute that stores objects. We were removing objects from the attribute without a problem with:

 "objectFacade.storeObjectAttributeBean(ObjectAttributeBean accRightsAtt)" 

except when there was one object left in the attribute and then it had to be removed. 

The error was the same as Reto's, even though the cardinality on the attribute that stored the objects was min = 0.

Could not update object attribute 'Access rights' due to validation exception:ValidationInsightException: Validation errors were found: rlabs-insight-attribute-14893: ErrorMessage{i18nKey='rlabs.insight.i18n.constraint.violation.ObjectAttributeValueBean.MinOne.value', parameters=[], additionalMessage=null}; 

Hana's suggestion helped us very much, but all of this is very misleading and not at all intuitive. Is there a suggestion to improve this? The error at least?

Cheers,
Marina

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
Newest, 4.14.0
TAGS
Community showcase
Published in Jira Service Management

Submit your Jira Service Management use case and win!

Hi everyone - in case you haven’t heard, we’re hosting the show of the century on November 10th: High Velocity: ITSM World Tour.     This virtual, concert-themed experience...

271 views 1 9
Read article

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