Toad World® Forums

Toad Script: Entity.Attributes[i].Domain returns undefined

Hi I’m trying to programmatically retrieve the domain of a table’s field.

We only use domains in our model, as shown below:

Senza nome.png

The code is the following:

 for (var counterAttr = 0; counterAttr < TableObject.Attributes.Count; counterAttr++)
       var attr = TableObject.Attributes.GetObject(counterAttr);

       Log.Information("Field[" +counterAttr +"]: " + attr.Name + " (" + attr.Domain + ")");

But unfortunately it outputs as follows:

Field[0]: LDAP_USED_GROUP_ID (undefined)
Field[1]: LDAP_DOMAIN_ID (undefined)
Field[2]: LDAP_USED_GROUP_NAME (undefined)

Any ideas?

Hello Tommaso,

Try using attr.Domain.Name instead of attr.Domain.

The changed code would look like this:

Log.Information(“Field[” +counterAttr +"]: " + attr.Name + " (" + attr.Domain.Name + “)”);

If all of your attributes have domains, then you don’t need to check for nulls (attributes which don’t have domains). If you would change your mind in the future and started using data types instead of domains in some attributes, simply put this condition into your code:

if (attr.Domain != null)
Log.Information(“Field[” +counterAttr +"]: " + attr.Name + " (" + attr.Domain.Name + “)”);



Great it works…eve in if it’s quite strange that

  • attr.Doman is undefined

  • attr.Doman.Name has the proper value (property from undefined object)

But it’s enough for our goal,

thx a lot