I have a requirement to attach ACH payment files (vendor payment journal > Generate Payments) to a new attachment in a custom table. My code below works in creating the attachment, but when I go to the attachment and press "Open" the file is blank. The actual file that is delivered to the user's screen (through standard code) is not blank so the attachment should match this one exactly. The file name and everything else comes across, but the content is just blank. Additionally, in the DocumentManagement::AttachFile method, parameter 5 'filecontent' is not null when I debug it. Am I missing an intermediary step like uploading the file to URL/Temp storage or blob? If so, how can that be done? Or do you see anything that needs to be tweaked in my code? Parameter 7 is optional.
[ExtensionOf(classStr(CustVendOutPaym))]
final class-
DocuRef docuRef;
if(file)
{
DocuRef = DocumentManagement::attachFile(tableName2Id('CE_BankIntegrationStorageTable'), bankIntegrationStorageTable.RecId, bankIntegrationStorageTable.DataAreaId, DocuType::typeFile(), fileContent, filename,'TXT',filename, 'ACH file');
}
-
//make file null here
next closefile();
}