Hi guys, Could someone show me how to have a report save one dataitem to an HTML while the report is being previewed. I would like the customer statement report to save to HTML for each customer whose email address is in the system so that the file can be emailed to that customer. Also I wanted to create a variable called EmailAddress and assign to it the value of the email address field in the customer table for the record the report is currently processing, use that variable as the filename for use in the next step, mailing the file. I have thought of using the CurrReport.Break but am not sure whether to put in the OnPostSection trigger of the footer but am not too sure about this. Any help would be appreciated, Thanks Temba
You can use the SAVEASHTML function to save the report as HTML from within C/AL. If you only want to save certain parts of a given report, I’m afraid you will have to create a new report containing only the information you need. Why do you think you need this extra variable? You could just use the customer’s email address as parameter for SAVEASHTML.
I have done something similar with Statements from the Sales & recievables module. Basically, if the customer had an email address on the customer card then a html file would be attached to an email and sent to the address defined, otherwise the statement would print out and be sent via post. Is this what you are attempting to do ??
Thanks for the replies, I was starting to think this must be a dumb question [:o)]That is exactly what I’d like to do @deanaxon and from the same module. To make things a little trickier, our email setup is Notes/Domino. Could you shed a little more light as which trigger would be most appropriate for this to happen. as for the variable, i guess i was going overboard, but the idea is to end up with a file for each customer, whose filename is the repective customer’s email address. Next step would be to mail that through domino. Thanks again
quote:
Originally posted by deanaxon
I have done something similar with Statements from the Sales & recievables module. Basically, if the customer had an email address on the customer card then a html file would be attached to an email and sent to the address defined, otherwise the statement would print out and be sent via post. Is this what you are attempting to do ??
Hi Temba, the solution to your problem is easier than you may think. Start with a new report based on the customer table, and on the “on after get record()” trigger do something like this: If “Email Address” <> ‘’ then begin FileName:=‘c:%1 %2.html’,“No.”,‘Statement’; Report.saveashtml(etc…) else begin Report.run(etc…) end; This then tells navision which report to use for each customer. You can use the same report id for both reports, but I created them as seperate reports for the follwing reasons: 1) Formatting of HTML reports are different to that of a normal Navision report. 2) I could set the print report to print out automatically without any user intervention As for the attachments to email; I was lucky that my client was using MS Outlook. This meant that I could use the standard simple MAPI integration as used in codeunit 397 Mail(I think thats the number anyway) Dean.
Hi Dean, Thanks for the help, I have looked at your code and tried to adapt it to my setup here. I placed the code in the OnAfterGetRecord trigger but it brings up syntax error, please advise. IF “E-Mail” <> ‘’ THEN begin FileName :=’\Mail01\nav_mail\statements%1.html’, “E-Mail”; Report.saveashtml(‘FileName’) ELSE begin Report.run(50075) end;
quote:
Originally posted by deanaxon
Hi Temba, the solution to your problem is easier than you may think. Start with a new report based on the customer table, and on the “on after get record()” trigger do something like this: If “Email Address” <> ‘’ then begin FileName:=‘c:%1 %2.html’,“No.”,‘Statement’; Report.saveashtml(etc…) else begin Report.run(etc…) end; This then tells navision which report to use for each customer. You can use the same report id for both reports, but I created them as seperate reports for the follwing reasons: 1) Formatting of HTML reports are different to that of a normal Navision report. 2) I could set the print report to print out automatically without any user intervention As for the attachments to email; I was lucky that my client was using MS Outlook. This meant that I could use the standard simple MAPI integration as used in codeunit 397 Mail(I think thats the number anyway) Dean.
When creating the file name using %1,%2, you must use the STRSUBSTNO function: FileName := STRSUBSTNO('\\Mail01\nav_mail\statments\%1.html',"E-Mail");
quote:
Originally nelson wrote: When creating the file name using %1,%2, you must use the STRSUBSTNO function: FileName := STRSUBSTNO(’\Mail01\nav_mail\statments%1.html’,“E-Mail”);
This is not strictly true. The way in which I coded this worked fine in GB v2.60
quote:
Originally temba wrote: I have looked at your code and tried to adapt it to my setup here. I placed the code in the OnAfterGetRecord trigger but it brings up syntax error, please advise.
Please see below : Start with a new report based on the customer table, and on the “on after get record()” trigger do something like this: