Skip to Content
0
May 09, 2018 at 09:55 AM

Creating an extended attribute in PD using VBS

458 Views

Hi,

Am trying to create an extended attribute within PD using vbs

It fails on line:

Set attr = Createobject(model.cls_ExtendedAttribute)

Object not supported - does anyone know how to create a new extended atrribute in a dataitem?

Thank you

Code looks like

ValidationMode = True 'Forces PowerDesigner to validate 
' actions and return errors in the event of a forbidden action
InteractiveMode = im_Batch ' Supresses PowerDesigner dialogs
' Main function
' Create an OOM model with a class diagram
Dim Model
Set model = CreateModel(PdCDM.cls_Model, "|Diagram=ClassDiagram")
model.Name = "Customer Management"
model.Code = "CustomerManagement"
' Get the class diagram
Dim diagram
 Dim cls
 Set cls = model.dataitems.CreateNew()
 cls.Name = "Customer"
 cls.Code = "Customer"
 cls.Comment = "Customer class"
 cls.Description = "The customer class defines the attributes and behaviors of a customer."
 ' Create attributes
 CreateAttributes cls
 ' Create methods
 CreateOperations cls
 ' Create a symbol for the class
 Dim sym
 Set sym = diagram.AttachObject(cls)
 CreateClasses = True
' Create attributes function
Function CreateAttributes(cls)
 Dim attr
 Set attr = Createobject(model.cls_ExtendedAttribute)
 '(PdOOM.cls_Attribute)
 attr.Name = "ID"
 attr.Code = "ID"
 attr.DataType = "int"
 attr.Persistent = True
 attr.PersistentCode = "ID"
 attr.PersistentDataType = "I"
 attr.PrimaryIdentifier = True
 Set attr = cls.CreateObject(PdOOM.cls_Attribute)
 attr.Name = "Name"
 attr.Code = "Name"
 attr.DataType = "String"
 attr.Persistent = True
 attr.PersistentCode = "NAME"
 attr.PersistentDataType = "A30"
 Set attr = cls.CreateObject(PdOOM.cls_Attribute)
 attr.Name = "Phone"
 attr.Code = "Phone"
 attr.DataType = "String"
 attr.Persistent = True
 attr.PersistentCode = "PHONE"
 attr.PersistentDataType = "A20"
 Set attr = cls.CreateObject(PdOOM.cls_Attribute)
 attr.Name = "Email"
 attr.Code = "Email"
 attr.DataType = "String"
 attr.Persistent = True
 attr.PersistentCode = "EMAIL"
 attr.PersistentDataType = "A30"
 CreateAttributes = True
End Function