Book a Demo

Author Topic: Element Keywords  (Read 5036 times)

MoMo

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Element Keywords
« on: December 18, 2007, 12:59:27 pm »
hello

 A simple question... Can we access to an element's keywords by automation?
What I try to do is to research an element (here a package) with a specified keyword:
Code: [Select]


foreach (EA.Element item in repository.GetElementsByQuery("Extended", "somekeywords"))
{
if ((item.Type == "Package") && (item.keywords =="somekeywords"))
 {
Package aPackage = repository.GetPackageByGuid(item.ElementGUID);
listPackage.Add(new EAPAckage(aPackage));

  }
}

"item.keywords" doesn't exist. (it works well with Alias but i use Alias for other things)
Also I can't cast an element to a package so I’m obliged to do a "second research" by guid to get the package.
There is another way to do that?
i'm using C#
thanks

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Element Keywords
« Reply #1 on: December 18, 2007, 02:53:04 pm »
For an element of type "Package", you can find the corresponding package ID in the MiscData(0) field.  I never actually realised that the same guid is used for both the Element and Package, but yes, looking up the package based an the element's GUID also seems to work.  Either way, you do need to call GetPackageByID or GetPackageByGUID to retrieve the EA.Package object.

Keywords should be available from the MiscData(4) field.

MoMo

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Element Keywords
« Reply #2 on: December 18, 2007, 03:32:32 pm »
i never used the MiscData attribute as i dont know what are the fields.
in the EA User Guide MiscData is not documented, can i find somewhere the description of the MiscData fields ?

thanks

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Element Keywords
« Reply #3 on: December 19, 2007, 05:02:38 am »
MoMo,

Actually, they are documented, in the object model section. The correspond to the PDATA fields in the schema. You should look the entry up, since there are a few things you will need to know, and they are documented.

David
No, you can't have it!