Hi,
I am programmer by profession and am new to navision. We had a requirement to import invoices generated on our CRM system directly to navision.
I would go bit in detail here, we have built a dataport to import invoices to navision from our CRM system. Now the dataport includes 3 tables, Sales Header, Sales Lines & Document Dimension, we create a csv file to match the dataport and the invoices were being imported fine for a month. After a lot of debugging the posting of the inovices also works perfectly. But we stumbled into to a problem now, when we try to import a new invoice for the same customer (whose invoice was posted successfully last month), the import gives the following error:
The following C/AL functions can be used only to a limited degree during write transactions (because one or more tables will be locked).
Form.RunModal() is not allowed in write transactions.
CodeUnit.Run() is allowed in write transactions only if the return value is not used. For example, 'OK := CodeUnit.Run()' is not allowed.
Report.RunModal() is allowed in write transactions only if 'RequestForm = FALSE'. For example, 'Report.RunModal(...,FALSE)' is allowed.
DataPort.RunModal() is allowed in write transactions only if 'RequestForm = FALSE'. For example, 'DataPort.RunModal(...,FALSE)' is allowed.
Use the COMMIT function to save the changes before this call, or structure the code differently.
Not sure what this error means, we are trying to frantically look around for a solution. Would appreicate if one of you guys can possibly help us with this.
Thanks and regards
Hitendra
0
Comments
Thanks
Regards,
Steven
Similar to what selece28 has said but to further explain (to the best of my knowledge)...
When you launch a Form, Report, DataPort with RUNMODAL (or CodeUnit with RUN) the one or more tables associated with these objects are locked. This cannot happen if there is a write transaction currently in progress.
COMMIT can be used to end the current write transaction but in a lot of cases using this command can and will be a big "no-no". [-X
[edit]
what matttrax said... yeah I got it all wrong :-#
So if you get called away, or forget that you're supposed to hit OK, then the table is locked until you remember.
To make the information stay in the database the transaction has to complete or you have to use a COMMIT statement. COMMIT unlocks any tables are you are writing to and close the transaction. So if a RUNMODAL comes after it there is no transaction occurring and thus no table locks.
You should avoid using COMMIT unless you absolutely have to. If you get an error later in your code that should have stopped processing all of your information will still be saved in the database. It also take significantly longer if you are committing after every INSERT / MODIFY.
Hope that helps.
My Blog - nav.education
You need to set SetHidedialogue function as you are inserting the header and the line.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Now the problem here is that if we try to import an invoice for a company (in the Sales Header) who has already a posted invoice in the "Sales Invoice Tables", we get the above error, but if we try importing for a new company using the same dataport, it goes in fine, hence, I don't understand that if this error comes as the table is locked or not commited then how does it accept the transaction for other companies. And above all we are not also importing directly to the "Sales Invoice Table" but to the initial "Sales Header" which we then go through normal posting routine.
Any help or suggestions really appreciated.
Thanks
Hitendra
We know disabling the CallFieldValidate check is not advisable, can any of you please suggest what the problem might possibly be. Or is there a way to check what does the CallFieldValidate function for SellToCustomer actually does, does it look for a key or something why it gives the error?
Thanks
You should turn the debugger on and see where you get this error. As the others have said it could be in the credit limit check. so do the following
before clicking on Ok of the dataport Click Tools -> Debugger -> Active make sure that Breakpoint on Triggers is not ticked.
Albert
while using my own notebook, it just fine
but in customer.... it appears warning like that
what should i do? anyone can help?
You are getting this error because a form is poping up in the middle of a transaction. Put the debugger on to see wich form and why.
Salut!
Author of the book Implementing Dynamics NAV 2013
Cursos Dynamics NAV (spanish) : http://clipdynamics.com/ - A new lesson released every day.
yes... after i debug the error is right here
My guess a form will pop up. You probably have to change the code and not validate.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
if we create the sales line manually it just fine...
no problem
Salut!
Author of the book Implementing Dynamics NAV 2013
Cursos Dynamics NAV (spanish) : http://clipdynamics.com/ - A new lesson released every day.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n