2016, Events, Sales-Post, Item Ledger Entry already exists

northyen
Member Posts: 14
Hello,
So the solution I'm trying to build involves posting "extra" item ledger entries, when posting a Sales Order under certain conditions (when a INSERT record event is fired by a third party table), AND using events.
So my sales order 1000 is containing these two lines:
Line No Item
10000 1000
20000 1001
When Sales-Post runs by line 10000 it setups up the item journal line, and calls the Item Journal Post Line codeuint. The first Item Ledger Entry is created with number 2000. This inserts the record in the third party table, from which my solutions posts another Item Journal Line. Now Item Ledger Entry No. is 2001.
When Sales-Post runs by line 20000, it does NOT find the next Item Ledger Entry No. as the codeunit is global, and have been set already. It just adds one to the number, resulting 2001. It doesn't know of any 2001 Item Ledger Entry, as the codeunit never asks the database for the next number.
Thus there's a conflict, since my event already grabbed that number.
So, what are my options, shy of completely abandoning the "per INSERT event" approch? Right now the only solution I see right now, is OnBeforePostSalesDoc, then looping over the sales line.
So the solution I'm trying to build involves posting "extra" item ledger entries, when posting a Sales Order under certain conditions (when a INSERT record event is fired by a third party table), AND using events.
So my sales order 1000 is containing these two lines:
Line No Item
10000 1000
20000 1001
When Sales-Post runs by line 10000 it setups up the item journal line, and calls the Item Journal Post Line codeuint. The first Item Ledger Entry is created with number 2000. This inserts the record in the third party table, from which my solutions posts another Item Journal Line. Now Item Ledger Entry No. is 2001.
When Sales-Post runs by line 20000, it does NOT find the next Item Ledger Entry No. as the codeunit is global, and have been set already. It just adds one to the number, resulting 2001. It doesn't know of any 2001 Item Ledger Entry, as the codeunit never asks the database for the next number.
Thus there's a conflict, since my event already grabbed that number.
So, what are my options, shy of completely abandoning the "per INSERT event" approch? Right now the only solution I see right now, is OnBeforePostSalesDoc, then looping over the sales line.
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