Navision imorting invoices issue
mhitendra
Member Posts: 6
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
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
-
Hi, This error usually happens when you run one of those RUN or RUNMODAL improperly, Did you do posting routine after import the Sales Header?
Thanks______________
Regards,
Steven0 -
I have recently had troubles with this error message and it was a pain in the butt for me to get around it. #-o
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 :-#0 -
If you use RUNMODAL, the object begin run is displayed on the screen and the user must interact with it in some way to get the process to complete. This is not allowed during a transaction because those tables being written to are locked, thus not allowing anyone else to write to them. The information is not made permanent in the database yet.
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.0 -
My guess the reason you are getting the message is because of creditwarning dialog openining up.
You need to set SetHidedialogue function as you are inserting the header and the line.0 -
Thanks for your reply guys. But just for your infomation we are not navision experts and have created the dataport in quite the normal way by selecting the tables and fields in a sequence. Then generating a CSV file to match the format and run the dataport, for which we select the CSV file generated.
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
Hitendra0 -
We tried importing the data one by one table and found that the error was because of the "CallFieldValidate" was enabled for fields SellToCustomer & BillToCustomer for the Sales Header table in the dataport. But this option will give an error (when checked) only while trying to import invoices for companies who already have a posted invoice in the "Sales Invoice Header" table.
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?
Thanks0 -
Hi
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.
Albert0 -
i have the same problem here...
while using my own notebook, it just fine
but in customer.... it appears warning like that
what should i do? anyone can help?0 -
Have you read all posts in this thread? Have you tried any of the possible solutions given?
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!Laura Nicolàs
Author of the book Implementing Dynamics NAV 2013
Cursos Dynamics NAV (spanish) : http://clipdynamics.com/ - A new lesson released every day.0 -
kitik wrote:Have you read all posts in this thread? Have you tried any of the possible solutions given?
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!
yes... after i debug the error is right here.
.
.
END;
SalesLine.Type := 2;
SalesLine.SetHideValidationDialog(TRUE);
SalesLine.VALIDATE(SalesLine."Cross-Reference No.",ItemCode);
SalesLine."Quantity" := ItemQuantity;
SalesLine."Ship-To Code" := SalesHeader."Ship-to Code";
SalesLine.VALIDATE(SalesLine."Unit Price",NetPrice);
SalesLine.INSERT(TRUE);
.
.
.
.0 -
well try and create the line manually and see what happens.
My guess a form will pop up. You probably have to change the code and not validate.0 -
ara3n wrote:well try and create the line manually and see what happens.
My guess a form will pop up. You probably have to change the code and not validate.
if we create the sales line manually it just fine...
no problem0 -
Keep debugging... what line of code inside the OnValidate trigger trows the error? Even more, maybe the error is thrown inside a function the OnValidate calls...
Salut!Laura Nicolàs
Author of the book Implementing Dynamics NAV 2013
Cursos Dynamics NAV (spanish) : http://clipdynamics.com/ - A new lesson released every day.0 -
make sure it's the same data when inserting the line manually.0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions


