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
Piotr Wycichowski
Is it something when a user tried to use any of AI commands in SERP? /Piotr W....
10:07 8 Nov 2024
Brittany McGrath
Thank you for your post Lilian. I see this post has been submitted twice and the second post is being addressed so I will close this duplicate. Thank you. ...
09:41 5 Nov 2024