PAGE.RUNMODAL ERROR

poppinspoppins Member Posts: 647
edited 2014-12-25 in NAV Three Tier
Hi everyone,
I am trying to run some code and hit the following error:
Microsoft Dynamics NAV
---------------------------
The following C/AL functions are limited 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. XmlPort.RunModal is allowed in write transactions only if 'RequestForm = FALSE'. For example, 'XmlPort.RunModal(...,FALSE)' is allowed. Use the COMMIT function to save the changes before this call, or structure the code differently.
---------------------------
OK
---------------------------
By debugging, I got the line which caused the error:
Rollback := NOT (CheckAvailability.RUNMODAL = ACTION::Yes);
What shall I do to avoid it?

Comments

  • archer89archer89 Member Posts: 337
    use CheckAvailability.RUN instead of CheckAvailability.RUNMODAL.

    regards
    best regards
    Franz Kalchmair, MVP
    Alias: Jonathan Archer

    please like / agree / verify my answer, if it was helpful for you. thx.
    Blog: http://moxie4nav.wordpress.com/
  • lvanvugtlvanvugt Member Posts: 774
    archer89 wrote:
    use CheckAvailability.RUN instead of CheckAvailability.RUNMODAL.
    Well ... could be, but it all depends on the context in which you are calling this, and what you are trying to achieve. Apparently (as the message says) you are changing something in the database (i.e. making your process a write transaction). So while changing something in the database, why are you having a PAGE.RUNMODAL execution?
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • poppinspoppins Member Posts: 647
    lvanvugt wrote:
    archer89 wrote:
    use CheckAvailability.RUN instead of CheckAvailability.RUNMODAL.
    Well ... could be, but it all depends on the context in which you are calling this, and what you are trying to achieve. Apparently (as the message says) you are changing something in the database (i.e. making your process a write transaction). So while changing something in the database, why are you having a PAGE.RUNMODAL execution?
    What I am doing is that I am modifying a writing a custom function to explode all the BOMs in a given sales order and calling codeunit 63 in my code.
    The CheckAvailability .RUNMODAL is a call to page 342 CheckAvailability to check the availability of each item (this call already exists in codeunit 311, I didn't add it myself).
    So, how can I go around this???
  • lvanvugtlvanvugt Member Posts: 774
    You should separate the two process: (1) checking availability (2) modifying the data. I.e. based on the result of (1) you can then execute (2).

    Of course, technically, you could with the process you have coded already, but can then only call PAGE.RUNMODAL after you have committed the modifications first 9allowing you to execute PAGE.RUNMODAL), but most probably that's functionally not what you want.
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • asmilie2b3asmilie2b3 Member Posts: 39
    Poppins, I wonder if you ever found a good solution for this one? I am having the same issue in NAV 2013, and just using the explode BOM function on a sales line for an item with insufficient inventory it errors with a runmodal error. At the same point in CU 311:

    Rollback := NOT (CheckAvailability.RUNMODAL = ACTION::Yes);

    I noticed there was a KB to fix it, and downloaded NAV.7.0.40118.AU object set and merged in the changes related to the inventory check. That fixed the issue when copying document, and in other cases. However the issue is still occuring when exploding BOM's. Very hesitant to put a COMMIT in there so would love to know how you or anyone else fixed this.
Sign In or Register to comment.