Book a Demo

Author Topic: GetByName generates error if element is not found  (Read 3432 times)

MV

  • EA User
  • **
  • Posts: 65
  • Karma: +1/-0
    • View Profile
GetByName generates error if element is not found
« on: August 09, 2011, 05:39:28 pm »
Hi ,

I am trying to update requirement elements in EA from excel sheet. This excel sheet contains details for existing EA elements as well as details for new elements.

I am trying to use GetByName function after taking requirement name form excel sheet. This function seems ok for existing elements but throws error if element is not found. I am using following statements.

Dim currentElement as EA.Element
set currentElement = elements.GetByName(f3_reqReference)

for existing elements the above statement works fine and gives me reference however for new element script gets terminated with error code as following <index out of bound>.

is there a way to check return from the function so that i can create a new element.....

thanks

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: GetByName generates error if element is not fo
« Reply #1 on: August 09, 2011, 05:59:02 pm »
If you want to keep using GetByName then you'll have to put in in a try_catch.
Otherwise I would suggest to put all elements in a native List and do some sort of Find operation on that.

Geert