Introduction:

Scenario: I had created an action button Print to run a report using REPORT.RUNMODAL, while running this report from the Windows Client an error is thrown as below.

Pre-requisites:

Microsoft Dynamics NAV 2017

Cause of this error:

RUNMODAL stops the  transaction and waits for the User interaction. Hence, all users are blocked (who need the table).

During a transaction, we are not allowed to open a object with RUNMODAL.

Resolution to the error:

Use COMMIT statement before you call the REPORT.RUNMODAL.
What does COMMIT statement do?

  • When the system enters a C/AL codeunit, it automatically enables write transactions to be performed.
  • When the system exits a C/AL code module, it automatically ends the write transaction by committing the updates made by the C/AL code.
  • This means that if you want the C/AL codeunit to perform a single write transaction, the system automatically handles it for you.
  • However, if you want the C/AL codeunit to perform multiple write transactions, you must use the COMMIT function to end one write transaction before you can start the next. The COMMIT function separates write transactions in a C/AL code module.

Example
The metasyntax below contains two write transactions. As execution begins, a write transaction is automatically started. Using the COMMIT function, you tell the system that the first write transaction has ended and prepare the system for the second. Once execution has been completed, the system automatically ends the second write transaction.

BeginWriteTransactions
(C/AL Statements) // Transaction 1
COMMIT
(C/AL Statements) // Transaction 2
EndWriteTransactions

The post Error Resolution to “Form.RunModal is not allowed in write transaction” in Microsoft Dynamics NAV appeared first on CloudFronts - Microsoft Dynamics 365 | Power BI | Azure.