Hi,
I got a problem adding a attachmentstram from docu ref on specific customers only on sales invoices.
So.. this problem occours only on some customers and only on sales invoices. The same customers on projinvoices have no problem.
It finds the docuref but the moment it try to addAttachment it exits the method and in output I have only this error.
Exception thrown: 'System.NullReferenceException' in Microsoft.Dynamics.AX.Framework.FileManagement.dll
I had a similar problem with the same customer group but with creating invoices. That time salesinvoiceheadertmp table didn't cleared data and blocked output on invoices lines.
Could be there a similar problem with a tmp table? Where could I look after?
if (docuRef)
{
System.IO.Stream stream = DocumentManagement::getAttachmentStream(docuRef); // <---
cmrFile = filePath docuRef.originalFileName();
System.IO.FileStream fileStream = new System.IO.FileStream(cmrFile, System.IO.FileMode::Create, System.IO.FileAccess::ReadWrite);
stream.CopyTo(fileStream);
fileStream.Close();
}