Forums

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

no such property: name for class: java.util.collection

sahere
Contributor
August 21, 2019

hi all,

I want to extract the value of components in the my scriptrunner postfunction as following

def s5 = ((String)(issue.components.name))

 

but it gives me following error. how can i handle this issue. any advise will be so appreciated

[Static type ckecking] - No such property: name for class: java.util.Collection

1 answer

1 accepted

2 votes
Answer accepted
DPKJ
Community Champion
August 21, 2019
issue.components // this is object of java.util.Collection

`issue.components` return Collection of components, and `Collection` class doesn't have `name` property.

You have iterate over this collection and get `name` for each value. In return you will get list of names. Something like this.

def names = [];
issue.components.each { component -> names.add(component.name) }
sahere
Contributor
August 21, 2019

many thanks for your reply. it gives me following information;

Result value:
[ProjectComponentImpl { name='Service1', description='', lead='s1', assigneeType='1', projectId='10811', id='11334' }, ProjectComponentImpl { name='Service2', description='', lead='s2', assigneeType='1', projectId='10811', id='11323' }]

but i want just to return component name as following

[Service1,Service2]

DPKJ
Community Champion
August 21, 2019

It is giving you a list of ProjectComponentImpl. You need to get value of name from each component now. So you need to iterate over this list.

In above code that I have posted, `def names` will contains your desired list of names of component.

sahere
Contributor
August 21, 2019

many thanks 

it works

DPKJ
Community Champion
August 21, 2019

Ah! you can accept answer and up vote it.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events