Hi,
The "record is not open" thing usually means the RecordRef going into table 1173 is not opened on the source record before InsertAttachment runs. Classic one after FactBox migrations.
In the old Document Attachment FactBox, the RecRef.Open and GetTable were happening inside the FactBox itself, so custom code never had to worry about it. The new Doc. Attachment List FactBox does it differently, the source record is passed in a different way, and if your code on Warehouse Receipts or Payment Request was relying on the old plumbing, the RecRef ends up empty or closed by the time SaveAttachmentFromStream is called. That is exactly why the error pops on line 4 of InsertAttachment.
Easiest fix, open the RecordRef yourself before calling SaveAttachmentFromStream. Something like
RecRef.Open(Database::"Warehouse Receipt Header");
RecRef.GetTable(WhseReceiptHeader);
DocumentAttachment.SaveAttachmentFromStream(InStream, RecRef, FileName);
One more thing that bit us last time on a similar case, the AttachmentsUpload OnAction on page 1178 has changed signature, and if your custom extension was subscribing to it or extending it, the parameters do not line up anymore. Worth opening page 1178 source and comparing with what your code expects.
If you want to be sure where it dies, just throw a Message before InsertAttachment with RecRef.Number and RecRef.IsTemporary. If Number is zero or RecRef is closed, you have your answer in two seconds.
✅ Tick the checkbox below to mark the answer as verified, if it helped resolve your question.
Regards
Gregory Mavrogeorgis