Book a Demo

Author Topic: programmatically search for Requirements  (Read 3321 times)

ngong

  • EA User
  • **
  • Posts: 275
  • Karma: +2/-2
    • View Profile
programmatically search for Requirements
« on: June 22, 2019, 11:08:10 pm »
I can manually search for Requirements in the Find in Project dialog of EA by selecting Requirements and Requirements in the first two fields an leave the third one empty. Then I get all requirements (gt 6000 in my case).

If I am entering

set rqs=Repository.GetElementsByQuery("Requirements","Requirements")

in a script I get a collection size of just above 200.

Where does the difference come from and what is the easiest way in VBScript to get a collection of all?
Rolf

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: programmatically search for Requirements
« Reply #1 on: June 23, 2019, 06:48:22 am »
Probably a
Code: [Select]
Repository.GetElementSet("SELECT * FROM t_object WHERE object_type='Requirement'", 2)should do it.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: programmatically search for Requirements
« Reply #2 on: June 24, 2019, 10:00:04 am »
I can manually search for Requirements in the Find in Project dialog of EA by selecting Requirements and Requirements in the first two fields an leave the third one empty. Then I get all requirements (gt 6000 in my case).

If I am entering

set rqs=Repository.GetElementsByQuery("Requirements","Requirements")

in a script I get a collection size of just above 200.

Where does the difference come from and what is the easiest way in VBScript to get a collection of all?
There's no parameter for the category in GetElementsByQuery. So the equivalent of your GUI search would be:
Code: [Select]
set rqs=Repository.GetElementsByQuery("Requirements","")Which means that you're going to get the same result as qwerty's suggestion. Although that also has the advantage that you're not going to be impacted by a change in the search definition or a new search named 'Requirements'.