Search code examples
ironpythonspotfire

How can I get the externalname of a column using IronPython in Spotfire?


Currently I need to change the name of a column depending on specific criteria but to do that I'd like to refer to that column by its ExternalName rather than its name.

aColumn = Document.ActiveDataTableReference.Columns["I_id"].Name 

unfortunately this doesn't work.

aColumn = Document.ActiveDataTableReference.Columns["I_id"].ExternalName 

Solution

  • you're very close! ExternalName isn't a property of the DataColumn object, which is, I suppose you've figured out, why your approach isn't working.

    in fact, ExternalName is an item represented by the DataColumnProperties.DefaultProperties class. you would actually access this as if it were a custom-defined Column Property like so:

    col_ext_name = Document.ActiveDataTableReference.Columns["I_id"].Properties["ExternalName"]
    
    print(col_ext_name)
    
    >> index_id