This topic is locked
[SOLVED]

 Send Mail for "Unselected" Record

3/12/2015 10:30:42 AM
PHPRunner General questions
R
rob_by68 author

Hi to everyybody.
I have a read only database, meaning users can only list and search records, but they're not allowed to

edit.

In List View i would like to add a button so that the record next to the pushed button could be processed

and sent to destination mail recipient.

I am able to successfully send an e mail, so mail server side everything is working fine, but the

problem is that the email that is received is blank or, better, does not contain any record data.
I think that the issue is caused by the fact that no record is really selected (checked).
Any suggestion on how to solve this kind of issue?
Thank you.
Roberto
Bologna - Italy

Sergey Kornilov admin 3/13/2015

$button->getCurrentRecord(); should work for you. Check example #1 at http://xlinesoft.com/phprunner/docs/inserting_button.htm

R
rob_by68 author 3/13/2015

Thank you Sergey.
I don't get it.
Records are displayed exclusivelu using a Report, nothing else.
My need is to send an email of the corresponding record, so basically when someone

clicks the button, data should be gathered.
In visual editor, i add the following code in the "On Server" tab of the button
$email_msg = "";
$email_msg.= "List of records";
$i=1;
while($data = $button->getCurrentRecord())
{
$email_msg.= "Record: ".($i++)."\r\n";
$email_msg.= "Field: ".$data["MyField"]."\r\n";
$email_msg.= "\r\n";
}
//send email
$email = "email@email.com";
$subject = "Sample subject";

runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $email_msg));



I receive the email, which contains exclusively the text "List Of Records", nothing else.
The example you provided gathers records and add them to another table, i have exclusively

to send an email to the defined recipient when the corresponding button is selected.

Since no records are editable, or if you prefer selectable (i am working on a report),

i don't know how that code can "understand" which record is processing, thus adding

data to email.
Thanks again for any suggestion.
Roberto

Sergey Kornilov admin 3/13/2015

In report you do not have access to underlying data. You can only use this functionality on regular List pages.

R
rob_by68 author 3/14/2015

Thank you Sergey,
i have tried the exact same code on a standard List View, obtaining the same result.
I have a table say name "MyTable" structured this way:
[Field1] [Field2] [Field3]
When i create the Standard List View with the button included i get:
[Field1] [Field2] [Field3]

(Button) [Value1] [Value2] [Value3]

(Button) [Value4] [Value5] [Value6]

(Button) [Value7] [Value8] [Value9]
Records are Read Only and displayed only in List View format, they are not editable or selectable.

What i would like to accomplish is, if user Press the Button on row 1, get Value1, Value2, Value3 and send an email

to a predefined mail address with the corresponding field values.

Same for other rows.
How can i accomplish this in PHP?
Again, thanks for any suggestion, need your help.

Sergey Kornilov admin 3/14/2015

Please check my answer one time, I have tested it before replying and it works.
Here is a picture for you

R
rob_by68 author 3/14/2015

Hi Sergey,
created New_Button.
Server tab:
$record = $button->getCurrentRecord();

$result["txt"]=$record["chiav_id_vett"];
Client After tab:
alert(result["txt"]);
Build the Project, List Page, Press New_button and get a "null" response.

Record exists as far as i can see it, but no data is retrieved and passed to the procedure.
Coold that be caused by the fact that all records are from external data source?
Thanx
Roberto

R
rob_by68 author 3/15/2015

I finally got it, and it was so simple.
When importing data from external source, no primary key was defined.
I defined the primary key and...voilà , everything works as expected.
Thanks again for your time and suggestions.
Roberto