cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

API: GetType in VB

Fboulart
Super Contributor

Hi there,

 

Mega 2009 SP5 CP6 and CP7.

 

Using the Abstract metamodel, I need to export the BPMN Element collection and get the Sub-MetaClass (eg. Organizational Process) for each item in this collection.

 

The GetType method should do the trick, as explains on p53 of the MetaStudio doc.  For some reasons, I get this error:

“Variable uses an Automation type not supported in VBScript:” 

 

Here's the code I'm using. Thanks for your help.

 

'MegaContext(Fields,Types)
Option Explicit

Sub CmdInvoke(mgobjSource as MegaObject, intCmdNumber as Integer)
Dim col_Participant_Elements As MegaCollection
Dim col_BPMN_Elements As MegaCollection
Dim col_OrgProcs as MegaCollection
Dim obj_Element As MegaObject
Dim obj_BPMN_Element as MegaObject
Dim obj_Object As MegaObject


col_BPMN_Elements = mgobjSource.GetCollection("BPMN Element")
col_OrgProcs = col_BPMN_Elements.GetType("Organizational Process")

For Each obj_Object In col_OrgProcs
  Msgbox obj_Object.shortName
Next

End Sub 
2 Replies

Fboulart
Super Contributor

Merci Jerome.

 

Thorough and specific as usual.

 

Cheers,

 

francois

jhorber
MEGA
MEGA

Hello François

 

As a general manner, use the ID of the metamodel element and not the name of the metamodel element/

 

Recommended

   Set col_BPMN_Elements = GetCollection("~JW7j6VRt9H40[BPMN Element]")

  or

  Set col_BPMN_Elements = GetCollection("~JW7j6VRt9H40")

 

Not recommended

  Set col_BPMN_Elements = GetCollection("BPMN Element")

 

See also http://community.mega.com/t5/custom/page/page-id/mega-kb-solution?sid=50120000000mqR5AAI

 

When using GetType for a collection, you need to quote the MetaClass ID and not the MetaClass Name

Example (VB script):

 

Set cBE = GetCollection("~JW7j6VRt9H40[BPMN Element]")
Print "Number of BPMN Element objects: " & cBE.count()
Set cOP = cBE.GetType("~gsUiU9B5iiR0[Organizational Process]")
Print "Number of Organizational Process objects: " & cOP.count()

 

 

Jerome