Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Emailing report with selection criteria

mateo
Posts: 10
Joined: Thu Feb 17, 2011 3:53 pm

Emailing report with selection criteria

Unread post by mateo »

Hello!

It's me once again, I'm just wondering if a report that requires a criteria can be attached
to an email using the emailIt functionality???

Is there a sort of parameter that I can add in specifying the report id in the emailIt function?
or there is another way?

Thanks very much in advance.

Rgds,
Mateo
shane
Posts: 100
Joined: Mon Jun 15, 2009 10:04 am

Re: Emailing report with selection criteria

Unread post by shane »

Hi,

I would love to help with your question, but I don't quite understand it, could you please explain with more detail exactly what you are trying to achieve

Regards
anorman
Posts: 66
Joined: Wed Apr 04, 2012 11:34 pm

Re: Emailing report with selection criteria

Unread post by anorman »

Actually, now that I am trying to email reports, I am having a similar problem..

I have a feeling I am just being really stupid on this one :-(

I have an invoice report that I need to feed to it the invoice number to print out an invoice

I have an extra button on the invoice screen that is pdfIt('INV',invoicenum);

I want to now be able to email it, but I cannot get the emailIt function to take the extra parameter invoicenum. So it emails me a blank invoice form..

what am I missing? (Sorry, I feel really stupid as it sounds like everyone else has this figured out.. but I am at a loss on this one <sigh>)

- Andre
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Emailing report with selection criteria

Unread post by admin »

Andre,

try using a hash variable of the invoice number on your edit Form.


Steven
anorman
Posts: 66
Joined: Wed Apr 04, 2012 11:34 pm

Re: Emailing report with selection criteria

Unread post by anorman »

I'm sorry Steven,

I don't follow..

This is what the email function is defined as

emailIt(pCode,pTo,pFrom,pSubject,pMessage,pFilename,pResponse,pType)

I assume the pCode is the actual name of the report form (in my case 'INV')..

Does the email function look for a 'hidden' pReportID variable or something that needs to be set to RecordID before I call it? Or so you need to 'add' an extra parameters to some field in the emailIt call itself?

Sorry, I think I've spent so much time on this one trying to figure it out that the answer is right under my nose, and I'm not seeing it :-( [Consider it now a deli and a steak run in NYC lol)
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Emailing report with selection criteria

Unread post by admin »

Andre,

Try this instead of #printIt1#.

Code: Select all

$query = $query . " where in_num = '#in_num#'";
You can use fields from the Edit Screen you are on as hash variables.

(in_num is of course, the invoice number)

Steven
anorman
Posts: 66
Joined: Wed Apr 04, 2012 11:34 pm

Re: Emailing report with selection criteria

Unread post by anorman »

Ah.. I think I approached the problem from a different angle, and don't understand what angle you are using..

For my pdfIt function, this is the code I am using


function GenInvoice() {

var myID = document.getElementById('recordID').value;

pdfIt('INV',myID);

}

Then I have an extra button that just calls GenInvoice() when I press it..

I wasn't aware that any field on the edit screen can be used as a hash variable.. That's really cool!

But that leaves my next question..

Where would I use that query string you demonstrated above in my JavaScript function (or anywhere else) to fill in my emailIt(pRecord,pto ....) function?

currently, I have a second JavaScript function on my form in custom code called SendINV() with the code as follows:

function sendINV() {
var myID = document.getElementById('recordID').value;

var pTo = 'anorman@superdata.com';
var pFrom = 'reports@superdata.com';
var pSubject = 'Invoice #' + myID;
var pMessage = 'Here is the Invoice';
var pFilename = myID;

emailSendIt('INV',pTo,pFrom,pSubject,pMessage,pFilename,'TRUE','PDF');
}

And then another button in "extra action buttons" that just calls this function..

The GenInvoice() function that shows the pdf invoice has worked perfectly for a while.. I'm at a loss to understand how to send the invoicenumber (in_num) to the emailSendIt function, however..

I even tied appending the 'INV' in the first field above (Which is the correct name for the report I want to email) with 'INV&printIt0=INV&printIt1=' + myID but that didn't work..

I have a feeling you have another way to call that function that I am completely misunderstanding, or not seeing altogether, as I don't have a clue where you would put the #in_num# hash variable or the $query = . " where in_num = #in_num" code anywhere..


Sorry, I'm feeling really stupid right about now.. I think I have the programming equivalent to writers block or something :-(
anorman
Posts: 66
Joined: Wed Apr 04, 2012 11:34 pm

Re: Emailing report with selection criteria

Unread post by anorman »

BTW: I am almost done with my new function that is basically emailIt with an added field that takes the recordID that you want to send to it..

I've actually modified code in reportemail.php , nuEmailForm.js, and form.php thus far.. haha.. I'm guessing you are going to come back with a "oh, no no no you do it this way" and negate all my work in 20 seconds LOL
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Emailing report with selection criteria

Unread post by admin »

Andre,

You can use hash variables in the php code you write, to help build the temptable (#dataTable#), that your report then displays.

When you open an Edit Form or update a field on an Edit Form, nuBuilder stores the field values in a table called zzysy_variables.

Then If you run an Activity (Procedure, Export or Report) it pulls these out and replaces any matching hash variables you have in the Activities PHP code with the values sitting in zzsys_variables, that belong to the Edit Form you are on.

You don't need to pass them through anything. Although, as you have discovered you can in some cases.

This is better if you are launching a Report from a certain line on a subform (where hard coding a hash variable wouldn't work as each subform field has a different prefix).

Too much information?

Steven
anorman
Posts: 66
Joined: Wed Apr 04, 2012 11:34 pm

Re: Emailing report with selection criteria

Unread post by anorman »

Steven,

There is no such thing as too much information when it comes to programming!!!!!

Now I get it, just put the selection logic in the report itself <duh>.. I NEVER even thought of that before!!!!! <Sigh>


And now I understand how you do it!

THANK YOU THANK YOU THANK YOU!!!! If you cannot tell, it's 4am.. I've been "up" all night trying to figure out what you meant, and how to get this thing working..

Like I said, my new function is almost done, along with modified form.php, nuEmailForm.js and reportemail.php :-)
Locked