How can I add a button for sending a report by email?

Questions related to using nuBuilder Forte.

How can I add a button for sending a report by email?

Unread postby absalom » Wed Apr 21, 2021 5:54 pm

Hi have a button on a form for triggering the nuRunReport("FR0") Javascript command, and it works fine for building and opening the PDF report. Could I have a second button for building and sending the PDF report by email?

When opening the console and typing nuEmailReportAction("FR0")

I get:
Code: Select all
Uncaught ReferenceError: nuEmailReport is not defined
    nuEmailReportAction https://gestion.psychologie-brest.fr/core/nuform.js?ts=20210421101738:2870
    <anonymous> debugger eval code:1
debugger eval code:2870:2

absalom
 
Posts: 25
Joined: Sat Apr 03, 2021 11:20 pm
nuBuilder Version: 4.5

Re: How can I add a button for sending a report by email?

Unread postby kev1n » Wed Apr 21, 2021 6:57 pm

Hi,

nuEmailReport () doesn't seem to exist in nuBuilder 4/4.5. and I didn't find any other function that would generate a report and send it.
So you would have to save the report first with nuRunReportSave()
and the send it with the nuSendEmail PHP function.

Let me know if that works for you.
kev1n
nuBuilder Team
 
Posts: 1697
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: How can I add a button for sending a report by email?

Unread postby kev1n » Wed Apr 21, 2021 11:47 pm

Example:

JavaScript:

Code: Select all

nuRunReportSave('FR0', null, reportCreated);

function reportCreated(filename, id) {

   nuSetProperty(''filename', filename);
   nuRunPHPHidden('sendemail',0);   

}


Then create a PHP Procedure with code sendemail and retrieve the filename in the PHP code and send the email:

$file = "#filename#";
Code: Select all
nuSendEmail('to@test.com','from@test.com','From','Content','Subject', [$file], true)


(Latest nurunpdf.php and nuajax.js required from Github)
kev1n
nuBuilder Team
 
Posts: 1697
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5


Return to General

Who is online

Users browsing this forum: No registered users and 17 guests