The following C/AL functions can be used only to a limited d

tompynation
Member Posts: 398
This code is being executed when a user clicks a button:
But this is giving me the 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.
...
How can i solve this ?
btnFase3 - OnPush() ItemJnlBatch.GET('ARTIKEL','O. GEWICHT'); lv_DocNo := NoSeriesMgt.TryGetNextNo(ItemJnlBatch."No. Series",WORKDATE); lv_ItemJnlLine.RESET; lv_ItemJnlLine.INIT; lv_ItemJnlLine."Journal Template Name" := 'ARTIKEL'; lv_ItemJnlLine."Journal Batch Name" := 'O. GEWICHT'; lv_ItemJnlLine."Posting Date" := WORKDATE; lv_ItemJnlLine."Line No." := lv_ItemJnlLine.GetNextLineNo('ARTIKEL','O. GEWICHT');; // lv_ItemJnlLine."Item No." := lv_ProdOrder."Source No."; lv_ItemJnlLine."Item No." := 'GRIND 1-3'; lv_ItemJnlLine."Document No." := lv_DocNo; lv_ItemJnlLine."Entry Type" := lv_ItemJnlLine."Entry Type"::"Positive Adjmt."; lv_ItemJnlLine.Quantity := Overgewicht; lv_ItemJnlLine.INSERT(TRUE); COMMIT; CODEUNIT.RUN(CODEUNIT::"Item Jnl.-Post",lv_ItemJnlLine);
But this is giving me the 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.
...
How can i solve this ?
0
Comments
-
why do you fill a "real" item yournal line and not, like in CU 80 or 90, a "hidden" Journalk (without inserting the lines in the journal) ?Do you make it right, it works too!0
-
1) Do not use constants, use some setup table to set the template and batch
2) Move the code into some function and call the functionfrom the OnPush, else you will loose the code when somebody delete the button etc.
3) Enable debugger and look where it will stop, there must be some oint in the no. series selection or somewhere else when the NAV is trying to show you some form, but the transaction already started.0 -
Also you write datas in a Journal that can be used by a user :!:
What is, if an user use the Journal 'ARTIKEL' / 'O. GEWICHT' ? U post your lines after create. If also a user insert there lines, these post you also. Is this correct? I think not or?
Why do you not create the lines and post them like the standard it does`?
Take a look into CU 80 or 90 in function "PostItemJnlLine()" and use the same way
RegardsDo you make it right, it works too!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions