Using Nav 5.0sp1.
I have a small data port I am using for testing. I use it to import a text file containing an order... which I have been using for days.
All of a sudden I start getting this error when I import the file...
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.
Now at first I was mystified as to what the problem was, but then I stepped through the debugger and hit on the following lines as being the culprit:
Form 343 - Check credit limit
CalcOverDurBalanceLCY()
CALCFIELDS ("Balance Due (LCY)");
Aha! so the client I'm using has gone over their credit limit.... but shouldn't this have generated an error.. I mean an error message from the form or something which a normal human being can deal with?
Anyone know how I can debug this? How can I catch it?
Ideally my dataport should be able to run and generate reasonable errors when things don't work... if one of the no-no functions is being used within the calcfields triggers of 'Balance Due (LCY)' then it would seem to me that this is a bug, no?
Ian
0
Comments
setHidevalidationdialog or something similar
You need to call the function first and set it to true.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
garak/bbrown,
By bug I meant that the dataport should be able to function from a button - if the user clicks on the button but is faced by an error saying that they can't run code because x, y or z but does not mention the cause then this would be unexpected behaviour since generating the same order manually *would* generate an alert dialog.
Unexpected and unreasonable behaviour is normally be caused by a bug.
It's not about how a user thinks the system should work. It's about how the designer intended it to work. If the system does not work how the designer intended, that's a bug. If it works as intended but not how the user wants it to work, that's a difference of opinion. Making it work the way the user wants it is called customization.
This error is telling you what is wrong, it tells you how you can solve the problem too ("... or structure the code differently"). That something is working when done manually doesn't necessarily mean that it will work when done in code. Do not forget that each user input is isolated transaction, but when running code, all is one big transaction. It is why the error is not there in user input (there is no write transaction before the form is opened), but it is in your process (you already started to write into the database).
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.