Quantcast
Channel: Embarcadero Community - Embarcadero Community
Viewing all articles
Browse latest Browse all 3212

Macro doesn't return correct results for 'Where Used'

$
0
0

When I access the 'Where Used' for LDM attributes via a macro, I don't get the same results as I see in the GUI. In my current test model, some of the entries I can see in the GUI are missing from the output. I'm currently awaiting resolution of a very closely-related problem (case 433170), though today's symptoms aren't exactly the same. Here's the relevant part of my macro: If attr.WhereUsedModelUsage.Count > 0 Then For Each whereusedobj In attr.WhereUsedModelUsage Print #2, " - used by Model = " & whereusedobj.ModelID & ", Entity/Table = " & whereusedobj.EntityID & ", Attribute/Column = " & whereusedobj.AttributeID & ", View = " & whereusedobj.ViewID & ", user-defined? = " & whereusedobj.UserMapping & ". Object GUID = " & whereusedobj.GUID If whereusedobj.ModelID "0" Then 'ignore items that cause macro to fail usedCount = usedCount+1 Set usedByModel = DiagramManager.ActiveDiagram.Models.Item(whereusedobj.ModelID) If usedByModel Is Nothing Then Print #2, " -- the referenced model does not exist" Exit For End If Set usedByEnt = usedByModel.Entities.Item(whereusedobj.EntityID) If usedByEnt Is Nothing Then Print #2, " -- the referenced entity does not exist" Exit For End If Set usedByAtt = usedByEnt.Attributes.Item(whereusedobj.AttributeID) If usedByAtt Is Nothing Then Print #2, " -- the referenced attribute does not exist" Exit For End If If attr.ForeignKey Then ' the Where Used att/col is a FK foreignUsed = "Yes" Else foreignUsed = "" End If If usedByModel.Logical Then ' the Used By model is LDM If usedByAtt.AttributeName = usedByAtt.LogicalRoleName Then ' att doesn't have a rolename roledUsed = "" Else roledUsed = "Yes" Print #2, " - attribute has a rolename" End If End If outstring = mdl.Name & sep & modelType & sep outstring = outstring & ent.EntityName & sep & ent.TableName & sep & attr.LogicalRoleName & sep & attr.RoleName & sep & foreignAtt & sep & roledAtt & sep outstring = outstring & usedByModel.Name & sep & usedByEnt.TableName & sep & usedByAtt.ColumnName & sep & foreignUsed & sep & roledUsed & sep & whereusedobj.UserMapping Print #1, outstring Else Print #2, " -- ignored this entry - model ID = zero" End If ' model ID = zero Next ' Where Used object End If ' where used count > zero I appreciate any help anyone can provide here - I can't see anything wrong with the logic.


Viewing all articles
Browse latest Browse all 3212


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>