ADD NewField Error: TableDef Object has no atribute "NewField"

2 posts / 0 new
Last post
Snape
Offline
Joined: 04/16/2019 - 08:25
ADD NewField Error: TableDef Object has no atribute "NewField"

Hi,
i try to add a new field in IDEA 10.3 via Python:
 
import win32com.client as win32comclient
import os
import sys
idea = win32comclient.Dispatch(dispatch="Idea.IdeaClient")
db = idea.OpenDatabase("File.IMD")
task = db.TableManagement()
field = db.TableDef.NewField()
field.Name ="DIFFERENCE"
field.Description = ""
field.Type = 1
field.Equation = "BALANCE-SUM"
field.Decimals = 2
task.AppendField(field)
task.PerformTask()
 
I get this Error:
 field = db.TableDef.NewFieldAttributeError: 'function' object has no attribute 'NewField'
 
My Solution:
Change the String "field = db.TableDef.NewField()" to:
TDef = db.TableDef()
field=TDef.NewField()

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Snape,

Sorry for not getting back to you sooner.  I just looked at some of my code and I also split it up into two lines.  Not everything translates exactly.

Brian