am i stupid or does navision suck?

I can't figure out what the hell I'm doing wrong with Navision. The documentation seems terrible and the example code is poor at best.

I'm trying to just insert a record into a table and I'm not getting any kind of error message that is meaningful to me. Just a "You cannot make any changes in the database from this trigger" which doesn't mean anything to me.

The code I've got is written using Python for Windows. The second last line is where things go wrong in Navision.

Anyone have any idea what's wrong here?

def test1():
cf = win32com.client.Dispatch("cfront.cfrontctrl.1")
#cf.HideError = True # turn off dialog errors

cf.ConnectServer('navision', 'tcp')
print "Connect status:", cf.LastError()

cf.OpenCompany('GAP Adventures Play')
print "Open Company:", cf.LastError()

tableNo = cf.TableNo('Sales Line')
print "Table No:", tableNo
print "Table Last Error:", cf.LastError()

resultCode, hTable = cf.OpenTable( 0, tableNo )
print "ResultCode [%r] -- TableHandle [%r]" % (resultCode, hTable)

hRec = cf.AllocRec(hTable)
cf.InitRec(hTable, hRec)

print "Record: %r" % hRec

docTypeID = cf.FieldNo( hTable, 'Document Type')
docNoID = cf.FieldNo( hTable, 'Document No.')
lineNoID = cf.FieldNo( hTable, 'Line No.')

print "Document Type fieldNo: %d" % docTypeID
print "Document No. fieldNo: %d" % docNoID
print "Line No. fieldNo: %d" % lineNoID

cf.AssignField( hTable, hRec, docTypeID, 1)
cf.AssignField( hTable, hRec, docNoID, 943924)
cf.AssignField( hTable, hRec, lineNoID, 10000)

result = cf.InsertRec(hTable, hRec)
print "Insert result: %r" % result
Parents Reply Children
No Data
Related
Recommended