cancel
Showing results for 
Search instead for 
Did you mean: 

How to get selected attribute in a variable?

Former Member
0 Kudos

Hi,

I'm working in LDM model where an attribute (Attribute1) has been used under multiple entities(Entity_A, Entity_B). There is no trace ability links between Entity_A.Attribute1 and Entity_B.Attribute1. So, when I run impact analysis on this attribute, it doesn't show me where else it has been used.

I'm trying to create a custom method to run from menu. This custom method (On EntityAttribute metaclass) will go through all EntityAttributes and list down all entities where this attribute has been used.

My question is : How do I get selected entity attribute from diagram into a variable which I can use to run a check against all entities in model.

Any help is greatly appreciated.

Thanks,
Arvind

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Dim AttSel

AttSel= ActiveSelection.Item(0).Code

This is what I was looking for  . AttSel will contain code of selected attribute. Same can be expended to entities if entities are being used on different subject area diagrams in a model.

GeorgeMcGeachie
Active Contributor
0 Kudos

I'd search based on Name rather than Code, in case you have any codes that are not synchronised with names. Make sure you check the selected object is an attribute (using isKindOf).

Former Member
0 Kudos

You can make a context-method for a right click on the collection of columns that is shown for the table in the columns tab.

The trick is to place the method and menu on the BaseColumn metaclass:

The reason for this is that the collection at the table level does not supply "Columns" but BaseColumns (as found in the metamodel objects help):

You can add the MetaClass to your extension by removing the filter on concrete classes when you add a metaclass to your extension:

Unfortunately you cannot retrieve a selection of objects from the list in this way. The activeselection appears to be empty when you get into the method.

Answers (1)

Answers (1)

GeorgeMcGeachie
Active Contributor
0 Kudos

Hello Arvind, welcome to SCN

If you want all attributes called "Name", "Description", "Status", "Attribute_1" etc to be the "same attribute", you could use a CDM instead of a LDM. In the CDM, every attribute has an underlying Data Item, and the model options allow you to enforce a standard that says that every attribute with the same name is the same Data Item. For that to work, you really need very specific Data Items and attributes, so my examples of "Name" and "Description" wouldn't be appropriate.

The chances are that converting your LDM to a CDM along these lines is more work than you want to undertake, so let me address the issue within the LDM.

In a Logical Data Model, the fact that attributes in multiple entities have the same name does not mean that they are the same attribute, it's just the result of the application of naming standards. They may be very similar attributes (such as the Name of something), but the attributes will all have different descriptions because they exist within different entities. (unless you use generic descriptions such as "The name of something", which are not very meaningful or useful). Every attribute can only be 'used' by one entity.

For the kind of traceability you're after, I suggest you use Domains, assuming that every instance of "Attribute_1" has the same data type and length, etc.. The quickest way to do this for a large model to use Excel:

  • export all your attributes to Excel (via Model | Entity Attributes), making sure you include the Entity and attribute names, and the Data Type, Length and Width properties
    • sort this by the attribute name, and make sure you really do have the same characteristics for attributes with the same name
  • In Excel you'll have a sheet of attributes, copy it to create a sheet called 'Domain'
  • In the Domain sheet, delete the 'Entity' column, sort by 'Name', and remove duplicate rows
    • now you'll have a list of domains with data types etc.
  • In the attributes sheet, make the entry in the 'Domain' column match the attribute name
  • Use the Excel import wizard to create the domains and match the attributes to the domains

If you model is a small one, you're probably better off doing this manually - once your domains exist, you can sort a list of entity attributes by the attribute name, and assign multiple attributes to a domain in one operation.