I guess I should know this already, and I thought I did, but having problems with a temporary table. I think it’s related to it being called via an event.
I have a requirement in which I have a purchase order, which is generated from order planning. The function has been changed so that instead of creating a separate purchase line for each purchase demand in order planning, it is create a single line with a reservation against the original demand (job planning lines).
When a warehouse receipt is created against this purchase order, then the purchase line is split into a line per original demand. So if a purchase order line was created based on demand from 4 different job planning lines, then it will also create 4 different warehouse receipt lines all referring to the same purchase line. So far so good!
Unless I did more code, then it standard would only update the first receipt line, so I need to loop each purchase line to insert the temporary receipt line records.
Codeunit 90 (Post)
Codeunit 5760 (Update temp rec)
Codeunit 90 (Finalize)
Codeunit 5760 (Find temp rec)
I did this by creating a new event, which is calling a new codeunit, which again calls the same codeunit and function to insert the posted receipt lines and update the temporary records.
Codeunit 90 (Post)
Event> Codeunit 50000
Codeunit 5760 (Update temp rec)
Codeunit 90 (Finalize)
Codeunit 5760 (Find temp rec)
The problem now occurs when finalizing purchase order. When trying to find the temporary records using CU 5760, then the temporary table is empty.
So the question is really, how to keep the update Temporary table and keep it “alive” in memory, so that I’m still able to finalize the posting.