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.
0