The below code is to download the attachments which are attached in Vendor Invoice journals
AP->Inquiries and reports->Invoice-> Invoice Journal
The above screen added new button to download the multiple selected records attachments.
[ExtensionOf(formControlStr(VendInvoiceJournal,ABCDownloadFile))]
final class ABC_VendInvoiceJournalButton_Extension
{
public void clicked()
{
FormButtonControl fbc = this as FormButtonControl;
VendInvoiceJour vendInvoiceJour;
DocuRef docuRef;
DocuValue docuValue;
str docURL;
next clicked();
FormRun formRun = fbc.formRun();
FormDataSource fds = formRun.dataSource();
vendInvoiceJour = fds.getFirst(true);
while(vendInvoiceJour.RecId!=0)
{
select firstOnly docuRef
where docuRef.RefTableId == vendInvoiceJour.TableId
&& docuRef.RefRecId == vendInvoiceJour.RecId
&& docuRef.RefCompanyId == vendInvoiceJour.DataAreaId;
if (docuRef.RecId)
{
docuValue = DocuValue::find(docuRef.ValueRecId);
if (docuValue.RecId)
{
docURL = File::SendFileToTempStore(DocumentManagement::getAttachmentStream(docuRef),docuValue.fileName+'.'+docuValue.FileType,classStr(FileUploadTemporaryStorageStrategy),true);
Browser browser = new Browser();
browser.navigate(docURL,true,false);
}
else
{
warning("No file attachment found for the selected record.");
}
}
else
{
warning("No document reference found for the selected record.");
}
vendInvoiceJour = fds.getNext();
}
}
}
No comments:
Post a Comment
Give me the commetns and solutions