Form.RunModal() is not allowed in write transactions.

imurphyimurphy Member Posts: 308
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

Comments

  • bbrownbbrown Member Posts: 3,268
    This is not a bug. A bug is when software does not work as intended. Just because it does not work the way you think it should does not make it a bug.
    There are no bugs - only undocumented features.
  • garakgarak Member Posts: 3,263
    this is not a bug. During a transaction, it's not allowed to open a object with rundmodal. Because runmodal stops the transaction an wait for the user interaction. So, all ather users are blocked (who need the table) until the user close the form.
    Do you make it right, it works too!
  • ara3nara3n Member Posts: 9,256
    on sales header and sales line, there is a function called
    setHidevalidationdialog or something similar

    You need to call the function first and set it to true.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • imurphyimurphy Member Posts: 308
    Thanks ara3n, wasn't aware such a function existed. I'll have to give it a go and see what effect it has.

    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.
  • bbrownbbrown Member Posts: 3,268
    "Unexpected and unreasonable behaviour" by whose definition? Yours or the designer/developer?
    There are no bugs - only undocumented features.
  • imurphyimurphy Member Posts: 308
    Ask a user
  • bbrownbbrown Member Posts: 3,268
    imurphy wrote:
    Ask a user

    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.
    There are no bugs - only undocumented features.
  • kinekine Member Posts: 12,562
    imurphy wrote:
    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.

    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).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.