Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Reto Zürcher January 8, 2021

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 9, 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)
Reto Zürcher January 9, 2021

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

Alex
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 12, 2023

@Hana Kučerová Greetings!
Tell me please, could you help me? It seems I encountered the same bug... Thanks for any help!
https://community.atlassian.com/t5/Jira-questions/Why-is-the-attribute-value-not-removed-via-the-listener/qaq-p/2557319

0 votes
Marina Veselić October 5, 2021

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
AUG Leaders

Atlassian Community Events