I am currently working on a Packing List report that needs to save as pdf automatically in a particular path in our server upon click of an action button in a Sales Order. I am new to development, I have tried following the saveaspdf method in the Microsoft website however when the action button was ticked now, an I/O Error shows even when I already deleted the codes I have done in the Visual Studio Code. Is there any sample code you can advise to achieve the first scenario I have mentioned above? Another twist to this is that, it should only save when the sell-to customer code is equal to Customer 1, Customer 2 & Customer 3...help me please! Will File Management Code Unit help me with this? Thank you in advance!
Thank you for helping me with this, I was able to achieve what you have shown on your video and it is really a great help for me. However, they instead of saving it in my C:Drive, they want that saved in a a certain location in our Server, like \\RAKFILESERVER\WAREHOUSE\PACKING LIST. Is there any way for this? Thank you soooo much!
Hi, The Report.SaveAsPdf method should be fine in the On-Pre version. It's a little weird.
Well, can the solution below give you some hints? Just using Report.SaveAs(Integer, Text, ReportFormat, var OutStream [, RecordRef) Method.
https://yzhums.com/wp-content/uploads/2022/01/CustomFilenameForReportExport.mp4
pageextension 50100 ZYSalesOrderExt extends "Sales Order List" { actions { addafter("Print Confirmation") { action(SaveConfirmationAsPdf) { Caption = 'Save Confirmation As Pdf'; ApplicationArea = All; Image = Export; Promoted = true; PromotedCategory = Category8; PromotedIsBig = true; trigger OnAction() var TempBlob: Codeunit "Temp Blob"; FileManagement: Codeunit "File Management"; OStream: OutStream; SalesHeader: Record "Sales Header"; RecRef: RecordRef; begin SalesHeader.Reset(); Clear(OStream); CurrPage.SetSelectionFilter(SalesHeader); RecRef.GetTable(SalesHeader); TempBlob.CreateOutStream(OStream); Report.SaveAs(Report::"Standard Sales - Order Conf.", '', ReportFormat::Pdf, OStream, RecRef); FileManagement.BLOBExport(TempBlob, 'Sales Order_' UserId '_' Format(CurrentDateTime, 0, '') '.pdf', true); end; } } } }
Hope this helps.
Thanks.
ZHU
Hi, I am totally new to this, I have replied on your response below...Thank you. :)
HI, thank you for the link, however we don't need it to run a request page. It should saves automatically upon click of an action in our Sales Header Page. I have tried creating the code however when I run it an error "An I/O exception occurred during the operation" pops up when I click the Action Button "Create WMS Shipment" in the Sales Header. Below is the sample code that I have created, can you please tell me where I gone wrong?
I would really appreciate your help on this. . Thank you.
Hi, I have some simple examples that I hope will help you.
Thanks.
ZHU
André Arnaud de Cal...
292,074
Super User 2025 Season 1
Martin Dráb
230,900
Most Valuable Professional
nmaenpaa
101,156