# Attribute.DataType returns "undefined"

**URL:** <https://forums.toadworld.com/t/attribute-datatype-returns-undefined/2660>\
**Category:** Toad Data Modeler\
**Created:** [March 20, 2012, 9:45am UTC](https://forums.toadworld.com/t/attribute-datatype-returns-undefined/2660 "2012-03-20T09:45:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![a\_valued\_customer](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@a\_valued\_customer](https://forums.toadworld.com/u/a_valued_customer)\
**Post date:** [March 20, 2012, 9:45am UTC](https://forums.toadworld.com/t/attribute-datatype-returns-undefined/2660/1 "2012-03-20T09:45:59Z")

</div>

Hi,

I’m iterating over all Attributes of an entity (trying to write a Liquibase XML from within a JScript Macro). But for some reason the call to “Attribute.DataType” always returns “undefined”.

The function that I’m using looks like this:

function writeTable(Table)  
{  
Output.WriteLine(’’);  
for (c=0; c \< Table.Attributes.Count; c++)  
{  
Col = Table.Attributes.GetObject©;  
if (Col.DataType != null)  
{  
dType = getLBType(Col);  
Output.WriteLine(’’);  
}  
else  
{  
Log.Information(“Column " + Table.Name + “.” + Col.Name + " has no data type!”);  
}  
}  
Output.WriteLine(’’);  
}

The function getLBType() is simply a big if that maps TDM types to Liquibase types and does the replacement of the parameters. If I use Col.DataType in the WriteLine() call directly it simply writes “undefined” as well.

What am I missing here? In a different script the same call works without problems.

Do I need to “initialize” something before I can access the DataType property?

---

<div class="post-metadata">

**Author:** ![a\_valued\_customer](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@a\_valued\_customer](https://forums.toadworld.com/u/a_valued_customer)\
**Post date:** [March 20, 2012, 9:52am UTC](https://forums.toadworld.com/t/attribute-datatype-returns-undefined/2660/2 "2012-03-20T09:52:14Z")

</div>

Silly me…

Of course it must be Col.DataType. **Name**

---

<div class="post-metadata">

**Author:** ![Vaclav\_Frolik](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/vaclav_frolik/32/12_2.png) [@Vaclav\_Frolik](https://forums.toadworld.com/u/Vaclav_Frolik)\
**Post date:** [March 20, 2012, 10:26am UTC](https://forums.toadworld.com/t/attribute-datatype-returns-undefined/2660/3 "2012-03-20T10:26:45Z")

</div>

Yes, it must end with .Name or other property.  
BTW: do not forget to declare variables in your scripts.  
\*\*var c, Col;  
\*\*Regards,

Vaclav

Message was edited by: vaclav
