Skip to main content

Field.Types

IDEA has 14 different field types.  To access it in the script you would use the field.type function which would return an integer indicating which field type it is.  I noticed something interesting about the field types, 4 of the types are for editable fields, so when you are creating the field you would use the editable field type but once they are created and you use IDEA to see what type of field it is IDEA views them as normal IDEA field types.  Something to remember if you are using any editable types in your script.

Here is a breakdown of the field types.

 

Constant Description  
WI_VIRT_CHAR Virtual Character 0
WI_VIRT_DATE Virtual Date 2
WI_VIRT_NUM Virtual Numeric 1
WI_VIRT_TIME Virtual Time 13
WI_BOOL Boolean 10
WI_MULTISTATE Multistate 9
WI_EDIT_CHAR Editable Character 7
WI_EDIT_DATE Editable Date 8
WI_EDIT_NUM Editable Numeric 6
WI_EDIT_TIME Editable Time 12
WI_DATE_FIELD Date Field 5
WI_CHAR_FIELD Character Field 3
WI_NUM_FIELD Numeric Field 4
WI_TIME_FIELD Time Field 11

donfirefox Thu, 08/06/2020 - 23:48

Thank you, it was very useful to me.  Let me make a question, how to use IDEA @functions, like @date(), in python? eg: field.Equation = "@Date()"
 

klmi Fri, 08/07/2020 - 02:58

In reply to by donfirefox


import win32com.client as win32ComClient

if __name__ == "__main__":
try:
idea = win32ComClient.Dispatch(dispatch="Idea.IdeaClient")
db = idea.CurrentDatabase()
task = db.TableManagement()
field = db.TableDef().NewField()
field.Name = "DATE"
field.Description = ""
field.Type = 2 #constant "WI_VIRT_DATE" unknown in Python
field.Equation = "@date()"
task.AppendField(field)
task.PerformTask()

finally:
db = None
idea = None
task = None
field = None