Search code examples
ironpythonspotfire

How to use document properties as variables in an IronPython Script to Change Column Names in Spotfire


I am aiming to write a script (that ill run with a Action Item Button) to take use a Drop Down Property Control to select a column in my Data Table, and then change the name to whatever I type in an Input Field Property Control.

My script is simple and below and works when I type the values of the column i'd like to rename (Currently "TWO") and the new name i'd like to use "THREE"

Application.Document.Data.Tables['DataTable'].Columns['TWO'].Name='THREE'

What I would like to do is using a document property I created OldName.Property in place of 'TWO" and another document property "NewName.Property" in the place of three. I thought I had set up the script paramters correctly but I guess I haven't because they aren't working.

My simple setup

Script and script paramters


Solution

  • You are using quotes (and in one case square brackets) around the property names TWO and THREE.

    This worked for me:

    Application.Document.Data.Tables['yourtable'].Columns[TWO].Name=THREE
    

    where 'yourtable' is a literal string (your table name). TWO and THREE are the input parameters. If you set them to type Property you can simply select a document property and click on it to set each of them.