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

Problem with a macro linked to a Meta WizardCreator

sgonthey
Super Contributor

Hello,

 

I want  to  put  the SQL Clause Type "out_of_line_constraint" by default  when I create a new SQL CLAUSE.

 

So I've created a new MetaWizardCreator on the Metaclass SQL CLAUSE and I've linked a new macro.


'MegaContext(Fields)
Sub OnWizInitialize (oManager)
  oManager.Mode = (oManager.Mode Or 1) - 1
End Sub

Sub OnWizRealize (oManager)
  Dim oRoot        As MegaRoot
  set oRoot = oManager.Template.GetRoot
 
  Set oTypeClause  = oRoot.getCollection(~OXjWKguQ1DJ0[SQL clause Type]).Item("out_of_line_constraint")
 
  if oManager.template.getCollection("SQL clause Type").count = 0 Then
          'Si pas de type ==> On relie  par défaut Out_of_line_constraint    
      oManager.template.getCollection("SQL clause Type").Add oTypeClause
        
      'On modifie le nom de la SQL Clause qu'on est en train de créer : nom de la table & _ CK
      Set oTable= oManager.template.getCollection("Table").item(1)
          oManager.Template.Name = oTable.Name & "_CK"
    end if

End Sub

The macro compile but when I test a  creation of a SQL CLAUSE, i've got his message :

 

Script error "Error(0x800a01c1) : Argument obligatoire: 'oRoot.getCollection'" at Line 14 :
 GIP-WizardForCreateSQLClause : Erreur d'exécution Microsoft VBScript

 

Could someone help me please ?

 

Thanks for your response,

 

Sandrine

 

2 Replies

sgonthey
Super Contributor

Thanks a lot , it works now !

 

Smiley Happy

 

Bye

 

Sandrine

 

lionel
MEGA
MEGA

Hello Sandrine,

 

it seems you have 2 errors in your code :

- You forgot the quotes for your getCollection :  oRoot.getCollection("~OXjWKguQ1DJ0[SQL clause Type]")

(and that is, according to me, why you have the error message)

- You can't retrieve an item from a collection with its short name. If I were you, I would use a getSelection instead of a getCollection (which means my first observation is not usefull anymore 🙂

 

Your code should look like this :

Set oTypeClause  = oRoot.getSelection("Select [SQL Clause Type] Where _Hexaidabs 'B19EB566422E00ED' ").item(1)

 Hope that helps 🙂

 

Lionel