Skip to main content

IdeaScript AppendField Error

Hey there, I have a problem appending a new field to my database.
I built a function that takes a string from my database I'm appending to, and gets a string from anouther database that I need to be the value in my new Field... I get a error on my "task.AppendField field" saying there is a syntax error
 
 
Option Explicit
Dim LedgerTransaction As Object
Dim LTRecordSet As Object
Dim LTRecord As Object
Dim EntryTypeDescription As String
Dim ColumnName As String
Dim Number As String
Dim LTtask As Object
Dim LTfield As Object
Dim Value As String
Dim LedgerParameters As Object
Dim LPRecordSet As Object
Dim LPRecord As Object
 
Sub Main
Call AppendNew()
End Sub
 
Function AppendNew()
Set LedgerTransaction = Client.OpenDatabase("LedgerTransactions.IMD")
Set LTRecordSet = LedgerTransaction.RecordSet
Set LTRecord = LTRecordSet.ActiveRecord
Value = LocateEtype(LTRecord.GetCharValue("ETYPE")) 
Set LTtask = LedgerTransaction.TableManagement
Set LTfield = LedgerTransaction.TableDef.NewField
LTfield.Name = "ENTRYTYPEDESCRIPTION"
LTfield.Description = ""
LTfield.Type = WI_CHAR_FIELD
LTfield.Equation = Value
LTfield.Length = 30
LTtask.AppendField LTfield
LTtask.PerformTask
Set LTtask = Nothing
Set LedgerTransaction = Nothing
Set LTfield = Nothing
End Function
 
Function LocateEtype(EType As String) As String
               Number = EType
               If (Number="0") Then LocateEtype = "None"
               If (Number<>"0") Then LocateEtype = EtypePull()
End Function
 
Function EtypePull() As String
' Open the database.
Set LedgerParameters = Client.OpenDatabase("LedgerParameters.IMD")
' Obtain the RecordSet from the database.
Set LPRecordSet = LedgerParameters.RecordSet
' Obtain the first record from the RecordSet.
LPRecordSet.GetAt(1)
Set LPRecord = LPRecordSet.ActiveRecord
' Get the column name
ColumnName = Column(Number)
EtypePull = LPRecord.GetCharValue(ColumnName)
' Clear the memory.
Set LedgerParameters = Nothing
Set LPRecordSet = Nothing
Set LPRecord = Nothing
End Function
 
Function Column As String
If(Len(Number)=1) Then Column = ("ENTRYTYPEDESC0" & Number)
If (Len(Number)=2) Then Column = ("ENTRYTYPEDESC" & Number)
End Function
 

Brian Element Fri, 09/25/2020 - 16:25

Hi Talon, unfortunately there are several problems with your code.  Can you explain what you are trying to do as it might be easier to do it directly in IDEA with joins and virtual fields then trying to do it in IDEAScript.

Thanks

Brian