Re: HAL to save an attached file to client
David Delač
12-19-19
Hello Paul,

Please repeat these steps to understand behaviour:

1. Create Invoice and fill it up as you would normally do it
2. Attach "test.pdf" to it
3. Create .hal file with code below and add it to halcust
NOTE: Replace IVr.SerNr = 10000007; with serial number of the invoice you just created
4. Make sure It's compiled by restarting and then navigate to Technics >> Reports >> Empty Report and run it

There are 2 possible outcomes:
• File will be opened and shown to user
• Save window will open and provide you with ability to save file on your machine

This depends on the second argument. If FALSE user will get option to save file somewhere on his machine and if TRUE file will be opened.



event startup
begin
SetLangMode(LangEnglish,"ENG",0);
Report("Empty Report",EmptyRClass,EmptyRn,0,modTC);
end;


event DefineWindows
begin
real x,h,h1,h2,h3,h4,h5,h6,h7,v,v2,l,vs,vm,f,t;

SetLangMode(LangEnglish,"ENG",0);
WindowBegin("Specify My Own Report ",EmptyRClass,CGRcW,RcType);
SetWRect(5,73,415,250);
v = 6; vs = 20; h = 120;
EndWindow;

end;

global
procedure EmptyRn(record RcVc RepSpec)
begin
Integer filenr;
record IVVc IVr;
record RLinkVc RLr;
record Attach2Vc Attach2r;
string 255 filename;
Boolean res;

StartReportJob("Empty Report");
EndHeader

IVr.SerNr = 10000007;
if (ReadFirstMain(IVr,1,true)) then begin
filename = "test.pdf";
filenr = 1;
while (ReadRecordLink(IVr,filenr,Attach2r,RLr)) begin
if (Attach2r.FileName==filename) then begin

res = true;
goto LExit;
end;
filenr = filenr + 1;
end;
end;
LExit:;

if (res) then begin
DownloadAttachedFile(Attach2r,false);
end;


EndJob;
return;
end;
Leave Comment
You can subscribe to notifications for this post by selecting the 'star' icon on the top right corner of the post.
Latest Posts
David Delač
Hi Piotr, The log entry:
2024-12-14 08:40:43 0.000 CallHal(IsHansaWorldCustomer) appears because the server is running with the verbosity=debug-detailed setting in its parameters.txt file. Thi...
09:43 16 Dec 2024
Brittany McGrath
Hi Vaughn, I can confirm this has been fixed now and is live in Standard ERP 2024-11-20 Version: 85556786. Thank you. ...
10:04 10 Dec 2024