This topic is locked
[SOLVED]

 Emailing with button

3/4/2018 10:08:13 AM
PHPRunner General questions
lefty author

I have the code below in a button on server event on list page , When I hardcode email the code sends the email . If I use $_SESSION value or $data value , I get error message using PHPrunner 9.7 . I had this working with session value

in 8.0. I am using inline add , but in 8.0 I did not need to add any other code .
$body = "";
while( $data = $button->getNextSelectedRecord() )
{
$body .= "Employee: ".$data["Employee"]. " Employee #: ".$data["EmployeeID"]."\n";

$body .= "Customer: ".$data["Customer"]. " Customer #: ".$data["CustomerID"]."\n";

$body .= "Allocated Item: ".$data["brand"]."\n";

$body .= "Cases: ".$data["cases"]." Bottles: ".$data["bottles"]."\n";

$body .= "Comments: ".$data["Comments"]."\n";

$body .= "\n-----------\n\n";

}
// send the email
$email ="test@test.com"; // This works fine

$email =$_SESSION["fsm_email"]; // This does not work I get the error message from code below error happended. readonly field

$email =$data["manager_email"]; // This also does not work this is actual value in database.
read only field from session value
$subject = "Allocation";
$arr = runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $body));
$result["txt"] = "Allocations were sent to your FSM.";
// if error happened print a message on the web page
if( !$arr["mailed"] )
{
$errmsg = "Error happened:
";
$errmsg.= "File: " . $arr["errors"][0]["file"] . "
";
$errmsg.= "Line: " . $arr["errors"][0]["line"] . "
";
$errmsg.= "Description: " . $arr["errors"][0]["description"] . "
";
$result["txt"] = $errmsg;
}

lefty author 3/4/2018

Solved !
;


needed to put session variable in before process event .