Errors while importing invoices to Navision


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. The posting of the inovices also working perfectly. But we stumbled into to a problem 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,


Since this is custom code you are going to have to give us some hint as to what your process does. The error is probably because you are trying to open a form when you still have uncommited transactions.

The reason that this happens is that if the system is in the middle of some sort of transaction there is a distinct possibility that the tables are locked (Atomic Operations). If a form or report is open and wating for the user to responde then the tables will be locked until the user interacts with the system.

The purpose of not allowing the code to do this is so that this does not happen, a user runs something, a form appears on the screen but the user is out to lunch and no one else can work cause all the tables are locked.



We are not using any custom codes here. This is just a simple dataport that copies data into the Sales Header, Sales Line and Document Dimension tables on Navision.

Since we are not Navision experts (just started working on this software recently), we haven’t gone to the coding part of it.


Thanks for your reply guys. But just for your information 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 committed 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.



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?


See its not hard to actually give the details. And doesn’t seem too much of a trade secret either. So not sure why you didn’t want to share this information. Now that you have its possible to help.

Your dataports are triggereing code, so you are calling NAV code. First you need to be aware that the issue is almost certainly not because of the fact that you have already imported a record, but in fact its due to some validation that happens. In your case it coul be custom code, but as you said you have ABSOLUTELY ZERO mods iin your system, and your NSC never made changes. So the most likely issue is Credit Control.

To identify the issue you need to manually enter the Invoice one field at a time and see when the window pops up. i.e. look at the datapot file, and manually type those information into a new Sales Invoice, at some point a warning box or message will pop up. that is what you need too resolve. If in fact it si credit warnings, then I suggest you go to the sales and recievables setup and turn off credit warnings.

Hi David,

Thanks for your prompt response. To be honest we did not have any intention to hide the code or anything of that sort, basically we just did the change and it worked, hence we thought of updating it back to the ticket. We being new to Navision, hardly have any idea of what should be reported yet, but we would gradually learn.

Thanks for your inputs, we will try what you suggested and identify where the error occurs. Will update you soon.



Hi, Hitendra

I would advise to set Credit Warnings on Sales & Receivables Setup to No Warning. By the scenario you are describing I would dare to guess that the cumulative debit due to multiple invoices may trigger the creditd warning form open.

That’s good to hear [Y]. Basically the thing is to post as much information as possible. I guess that to you, a Dataport does not seem like a customization, but really it is. You are callign lots of NAV triggers as well.

The key is to give all the correct information, as much as you know. Also its odd that you are doing these mods by your self, really your NAV partner should be working with you and training you.

Also if you have your answers, please click the [MARK AS ANSWER] box on the thread that helped yo, and give the thread a star rating to help the next person know what works and what doesn’t.

Hi David,

You were right mate it was the Credit Warnings which was creating the problem, once turned off and set the CallValidate for SellTo & BillToCustomer to “ON”, and did a new import and it worked perfectly.

Also, is there a way to check what the CallToValidate code does for each fields, this would help us understand what we are doing, better.

Thanks for your help guys, this forum is more helpful than our NAV partners, thats the reason why we preferred to do it ourselves.

Appreicate all your help



Ooops, I had notread David’s post to the end! He already had suggested the same thing. [:$]

There is never too much information Anna, also the fact that we both made the same comment helps reinforce it.

David is right Anna, you basically confirmed what he said and that helps ensure that we are on the right path.


Unfortunately you will need a developers license to see the code.

Glad the site is of benefit to you.

Hi David,

We have posted another query in this forum. Can you please check that and advise?