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(); }
This did the trick! Thanks Martin
Aren't you already at the end of the stream? Maybe you just need to reset the position: fileContent.Position = 0.
What is the file type when you are downloading it. Is it downloaded as text file?
Also try to debug inside the attachFile method of Document management. On the File information tab check whether file type is populated on document management form.
Also try the code like below.
http://www.theaxapta.com/2013/04/x-code-for-document-attachment.html
Thanks,
Girish S.
Here is my update code. The txt file export is getting generated (I can download it), but it is just blank still.
if(file) { DocuRef = DocumentManagement::attachFile(tableName2Id('CE_BankIntegrationStorageTable'), bankIntegrationStorageTable.RecId, bankIntegrationStorageTable.DataAreaId, DocuType::typeFile(), fileContent, filename,'TXT',filename, 'ACH file'); }
Here is my updated code. Still experiencing blank file. Txt file itself generates but its just blank.
You need to either pass the file type in the file name or pass the file type in the arguments.
Just try the below code and check.
DocuRef = DocumentManagement::attachFile(tableName2Id('CE_BankIntegrationStorageTable'), bankIntegrationStorageTable.RecId, bankIntegrationStorageTable.DataAreaId, 'File', fileContent, filename,'TXT',filename, 'ACH file');
Thanks,
Girish S.
Hi Girish. thanks for your reply.
My file name is a string, in this case it is 'ACH_02212023 03409'. The file type is a txt file.
Hi tristansenk99,
What is the file name and file type you are attaching.
May be the file type you are uploading is not supported in document management.
Thanks,
Girish S.
André Arnaud de Cal...
291,965
Super User 2025 Season 1
Martin Dráb
230,836
Most Valuable Professional
nmaenpaa
101,156