0

I'm working on a script to extract source to target data from powerdesigner 16. I have a table that is sourced from multiple mappings in powerdesigner MAPPING_1, MAPPING_2, ETC. I can't figure out how to set the default mapping with vba code. I'm currently access the mappings with the code below. It will access the default mapping that was active when I last saved my data model. If anyone has insight on how to do this I would be very greatful.

Thanks

'
' get the table
'   Dim mytable, col, cm
    mytable = 'CUSTOMER_STAGING'
    Dim obj As PdCommon.IdentifiedObject
    Set obj = baseModel.FindChildByCode(mytable, cls_Table)

    For Each col In obj.Columns
       For Each cm In col.Mappings
       Next
    next
Community
  • 1
  • 1
user3120960
  • 179
  • 1
  • 3
  • 11

1 Answers1

0

Not exactly the same objects, as I started playing with Conceptual Models. Two sources, and one target, all with entities named Entity_1, Entity_2, with the mappings set as excepted by the wizard.

Not exactly the same code, as I started playing with VBScript...

But it seems I was able to change the default mapping, just by setting the DefaultMapping attribute:

option explicit
dim myname
myname = "ENTITY_1"
Dim obj : Set obj = ActiveModel.FindChildByCode(myname, cls_Entity)
output "default: " & obj.defaultmapping
dim cm,changed
changed = false
For Each cm In obj.Mappings
   output cm
   if cm <> obj.defaultmapping and not changed then
      output "set to " & cm
      changed = true
      set obj.defaultmapping=cm
   end if
Next
output "default: " & obj.defaultmapping
pascal
  • 3,287
  • 1
  • 17
  • 35