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
If you didn’t use the search button on this forum I guess it’s the first one…
Thanks! Your reply was completely useless! So what am I doing wrong here? I have searched for “You cannot make changes…” but I haven’t found anything that has helped. The only thread I can find is this one: http://www.mbsonline.org/forum/topic.asp?TOPIC_ID=2837&SearchTerms=from+this+trigger And it’s not terribly useful either. vic
I dunno…I think it might be you. [;)]
Hint #2: You need to begin a transaction before you can write to the db…
hi all, Going back over my original 2 posts - i’ve just been having an extremely frustrating time getting any kind of support from our Navision supplier with respect to getting some functioning code. I apologize to everyone (i know it’s late), but i am sorry for being an ass. How do I go about setting up transactions? For that matter, where are you guys looking for reference code when you have problems? The only thing that seems to be useful to mee is this PDF called “w1w1cfront.pdf” witha title “C/Front reference guide”. Unfortunately, my navision supplier can’t help me out in compiling any of these samples. Although I am a ninja on UNIX, I am a moron on Windows and I can’t figure out how to do simple compiles.
quote:
I dunno…I think it might be you. [;)]
Originally posted by speetz - 2004 Oct 13 : 20:48:50
Com’on guys, be nice to this guy. Victor, before you say Navision “suck”, understand the whole situation before you say something “suck”. Cause saying stuff “suck” will not earn you any help from the people in this forum. There are a few things you need to mention before anyone can help you. Looks like you’re trying to insert something into the sales line or purchase line using C/FRONT. 1. What is the business problem you’re trying to solve? 2. Is the referencing purchase/sales header properly created already? 3. When you do this, do you know you cannot validate fields in Navision?
Thanks, 1. What is the business problem you’re trying to solve? I have a project where I need to create, update and read records between Navision and our own internal software. Our Navision rep suggested using the COM interface. My requirements will have me hitting a variety of tables and inserting/update/reading records from them at any given time. 2. Is the referencing purchase/sales header properly created already? I have no idea what you’re talking about. All I’ve been told by our Navision rep is that the code I have “should work”. How do I go about creating a purchase/sales header. 3. When you do this, do you know you cannot validate fields in Navision? Again - I have no idea what you’re talking about. What validation is required? Isn’t there some way to just create a record in table a’la SQL? vic
The documentation for C/Front is relatively scarce, because: 1) You are expected to posess a mastery of the C/SIDE development environment. 2) You can do a lot of damage in a very short while if you do not understand the C/SIDE environment. That said, there are a few places to look for examples:
- sample.c is a C-language demo of C/FRONT dll features…
- cfront.chm is a WinHelp file for the C/FRONT ocx…
-
cfront.xls is an Excel spreadsheet with VBA code examples…
To enable writing to the database, you must begin a write transaction. Then, when all writes are finished, you must end the write transaction. Of course, if an error occurs, you must abort the write transaction. In your example above, this would look something like this:cf.BWT() result = cf.InsertRec(hTable, hRec) if (result) cf.EWT() else cf.AWT()
I must caution you again, however, that there are all sorts of issues that haven’t been dealt with here, especially when inserting Sales Lines into a Navision db. Proceed with care, and good luck!
quote:
Thanks, 1. What is the business problem you’re trying to solve? I have a project where I need to create, update and read records between Navision and our own internal software. Our Navision rep suggested using the COM interface. My requirements will have me hitting a variety of tables and inserting/update/reading records from them at any given time. 2. Is the referencing purchase/sales header properly created already? I have no idea what you’re talking about. All I’ve been told by our Navision rep is that the code I have “should work”. How do I go about creating a purchase/sales header. 3. When you do this, do you know you cannot validate fields in Navision? Again - I have no idea what you’re talking about. What validation is required? Isn’t there some way to just create a record in table a’la SQL? vic
Originally posted by victoratgap - 2004 Oct 13 : 23:29:39
Ok… If you don’t know what I’m talking about, then it’s probably better that you don’t start any project where you have to insert/modify/delete data into the Navision tables. Yes, technically, you can do anything in the SQL tables, however, by doing so, you might cause serious irreversable damage to the Navision data. Try learning Navision first, especially the programming portion , then you’ll understand more on how to interface with it.
quote:
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.
I think Victor’s opening diatribe contains a good point though. It is a terrible and unrelated error message (borrowed from a different error situation altogether within c/side) for such a simple mistake. I think it should be changed to something like “You cannot make database modifications because you have not yet begun a transaction.”
But I think the point made above about learning more about developing in Navision prior to trying to add records from a third party solution is apt and if that was the case then you would have seen this message a hundred times before and known its meaning. Because Navision is a complex interrelated financial system you have to know the relationships between records and the validation code behind certain fields before you should consider adding records. I’ve just heard this diatribe so many times from people because Navision is so stupid it wont let them add records to stuff the system up. I mean that really sucks [:D]
Interesting response, but I would counter that Navision support companies shouldn’t present Navision as a simple system to integrate with if it’s not as simple as adding records into a SQL database. So if I’m completely fair - I’d say I’m most frustrated with Microsoft’s partner companies which seem to completely lack any credibility to support their products. I’m used to used open source products where I can always either A) figure out the solution my self by looking at the code, or B) get a response online within 3 hours on a newsgroup or mailing list. But I digress. I’ll tryout that transaction settting with BWT and EWT. Where cna I read up on the validation rules for Navision? The documentation seems very disjointed.
quote:
Interesting response, but I would counter that Navision support companies shouldn’t present Navision as a simple system to integrate with if it’s not as simple as adding records into a SQL database. So if I’m completely fair - I’d say I’m most frustrated with Microsoft’s partner companies which seem to completely lack any credibility to support their products. I’m used to used open source products where I can always either A) figure out the solution my self by looking at the code, or B) get a response online within 3 hours on a newsgroup or mailing list. But I digress. I’ll tryout that transaction settting with BWT and EWT. Where cna I read up on the validation rules for Navision? The documentation seems very disjointed.
Originally posted by victoratgap - 2004 Oct 15 : 04:34:56
To be more fair, how many of these Navision solution centers have you spoken to and worked with? It may be the case where you’re using a solution center that is new and is inexperienced in Navision. For the record, Navision is easy to interface with. But you just have to know what you’re doing, as with any system or program you’re trying to integrate with. Just because you don’t understanding something, doesn’t make it “suck”.
I know that for many people who are gurus in one or another progamming language, the idea of using an ODBC interface is repugnant. But we have had a number of customers and associates have considerable success in interfacing with Navision using simple ODBC interface techniques from a variety of language tools. Specifically we had a client use multiple versions (over time) of Delphi to insert Sales Orders in Navision from their custom product configuration and quoting system. Secondly a suggestion to folks who want to give us the choice that Victor gave us - since many of us are sure that Navision does NOT suck, that only leaves one option available to answer his question.
Victor, Many of the postings that reply to your request have highlighted the danger of pushing records into Navision tables at the database level. Are you aware that there are alternative methods of integrating Navision to other apps that do not have this issue, principally the Navision Application Server (NAS)? This technology enables you to write C/SIDE code that respects all of the internal validations and business rules of Navision and fire it from an external app. Initially it would be slightly more time consuming and costly than the C/FRONT approach but once the frame work is in place it is much more reliable and flexible solution. If you want to look in to NAS further it is included on the Navision product CD or you should find many related postings on this forum. Chris.
Talking With Navision: Say Hello to Navision and Expect Navision To Be Polite http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnav/html/tknavision.asp This is a new article
Victor, you are not stupid. NAV is rubbish, but most of us have no choice but to use this rubbish. Anyone who says anything else has built a career around it and is desperately clinging to it as olde people tend to do near their death, which is especially sad bc we are supposed to be working in the tech sector.
Nathan,
Maybe I’m old, but I wasn’t when I started working with NAV. But your comment is not welcome here and neither are you!
Who is stupid? The people who loves NAV (like me), despite its flaws (yes its not perfect)? Or those who despite what they think about NAV continues to work with it instead of finding a new career?
To me it sounds like you were still attending elementary school when the last post on this thread was written 9 years ago! If you cannot comment in a more positive way, then please don’t comment here at all!
Dear Derik,
Thank you… The fact that the first result from my google search was a decade olde post is proof, in and of itself.