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}
;
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.