The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

How to set multiple value to insight attribute using scriptrunner...

Shishira
April 28, 2023

I am trying to pass arraylist ie "Values"  with multiple values to have an insight attribute updated with multiple values using below command

def new_attribute_value = objectAttributeBeanFactory.createObjectAttributeBeanForObject(InsightObject, Attribute_type_object, Values as String )
objectFacade.storeObjectAttributeBean(new_attribute_value)
but getting error as below
com.riadalabs.jira.plugins.insight.common.exception.ValidationInsightException: ValidationInsightException: Validation errors were found: rlabs-insight-attribute-76576: ErrorMessage{i18nKey='rlabs.insight.i18n.constraint.violation.ObjectAttributeValueBean.MinOne.value', parameters=[], additionalMessage=null}; at com.riadalabs.jira.plugins.insight.services.validation.ValidateObjectImpl.validateObjectAttributeBean(ValidateObjectImpl.java:149) at com.riadalabs.jira.plugins.insight.services.core.ObjectServiceImpl.storeObjectAttribute(ObjectServiceImpl.java:1021) at com.riadalabs.jira.plugins.insight.channel.external.api.facade.impl.ObjectFacadeImpl.storeObjectAttributeBean(ObjectFacadeImpl.java:122) at com.riadalabs.jira.plugins.insight.channel.external.api.facade.impl.ObjectFacadeImpl.storeObjectAttributeBean(ObjectFacadeImpl.java:115) at com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade$storeObjectAttributeBean$3.call(Unknown Source) at Script574.run(Script574.groovy:99)

is there any other way to update multiple values to insight attribute 

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
PD Sheehan
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 Champions.
April 28, 2023

First off... it's bad practice in Java/groovy to capitalize variables. Then it becomes too difficult to differentiate between class names and instances of classes.

But if your "Values" variable contains an ArrayList and you want each of them to generate an ObjectAttributeValue, you can't cast it as a String.  You must cast it as an Array of strings.

Like this:

def new_attribute_value = objectAttributeBeanFactory.createObjectAttributeBeanForObject(InsightObject, Attribute_type_object, Values as String[] )
objectFacade.storeObjectAttributeBean(new_attribute_value)

Notice "as String[]" instead of "as String"

TAGS
AUG Leaders

Atlassian Community Events