Page 1 of 1

Email_Sending event

Posted: Wed Mar 15, 2017 12:57 am
by droogers

Hello,

I made a view with an inner join. When I add a record an email is sent. This works good.
The only problem is that not all field are showed in the mail. The field "naam2" in't showed up. This field is from the inner join table.
This is the code from the mail function:

function Email_Sending(&$Email, &$Args) {
//var_dump($Email);
//var_dump($Args);
//exit();
if (CurrentPageID() == "add") { // If Add page
$Email->Format="HTML";
$Email->Charset="ISO-8859-1";
$Email->Recipient = $Args["rsnew"]["naam1"]; // Change recipient to a field value in the new record
$Email->Subject = "Opgave"; // Change subject
$Email->Content = "\nBeste ".$Args["rsnew"]["naam2"].",<br><br>
Bedankt voor je opgave.<br>
Ik kom: ".$Args["rsnew"]["id2"]."<br>
Ik kom naam2: ".$Args["rsnew"]["naam2"]."<br>
Je opgegeven gegevens zijn als volgt:<br>
Graag ontvangen we 1 week voor de activiteit je betaling op bankrekening NL52 INGB 0000 6517 00 t.n.v. conferentiecontact Calvijn.<br><br>
Groeten en tot het aanstaande weekend,<br>
Jose van Duinen</body></html>";
}
return TRUE;
}


Re: Email_Sending event

Posted: Wed Mar 15, 2017 12:28 pm
by mobhar

Use "ew_ExecuteScalar" global function to get your desired value from a Table or a Database View.

Please read "Some Global Functions" at the bottom of "Server Events and Client Scripts" topic from PHPMaker Help menu for more info and example.


Re: Email_Sending event

Posted: Wed Mar 15, 2017 4:34 pm
by droogers

Thanks, but where do I have to place the code:

$value = ew_ExecuteScalar("SELECT naam2 FROM view1");


Re: Email_Sending event

Posted: Wed Mar 15, 2017 5:07 pm
by mobhar

In the same "Email_Sending" server event.


Re: Email_Sending event

Posted: Wed Mar 15, 2017 6:16 pm
by droogers

I tried this code but I got an empty page:

function Email_Sending(&$Email, &$Args) {
//var_dump($Email);
//var_dump($Args);
//exit();
if (CurrentPageID() == "add") { // If Add page
$Email->Format="HTML";
$Email->Charset="ISO-8859-1";
$Email->Recipient = $Args["rsnew"]["naam1"]; // Change recipient to a field value in the new record
$Email->Subject = "Opgave"; // Change subject
$Email->Content = "\nBeste ".$Args["rsnew"]["naam2"].",<br><br>
$value = ew_ExecuteScalar("SELECT naam2 FROM view1")
Bedankt voor je opgave.<br>
Ik kom: ".$Args["rsnew"]["id2"]."<br>
Ik kom naam2: ".$Args["rsnew"]["naam2"]."<br>
Je opgegeven gegevens zijn als volgt:<br>
Graag ontvangen we 1 week voor de activiteit je betaling op bankrekening NL52 INGB 0000 6517 00 t.n.v. conferentiecontact Calvijn.<br><br>
Groeten en tot het aanstaande weekend,<br>
Jose van Duinen</body></html>";
}
return TRUE;
}


Re: Email_Sending event

Posted: Wed Mar 15, 2017 6:32 pm
by mobhar

Change:
Ik kom naam2: ".$Args["rsnew"]["naam2"]."<br>

to:
Ik kom naam2: ".$value."<br>


Re: Email_Sending event

Posted: Wed Mar 15, 2017 6:53 pm
by droogers

I changed the code and now it works. Thanks.

function Email_Sending(&$Email, &$Args) {

	 //var_dump($Email);
	 //var_dump($Args);
	 //exit();

	if (CurrentPageID() == "add") { // If Add page
		$Email->Format="HTML";
		$Email->Charset="ISO-8859-1";
		 $Email->Recipient = $Args["rsnew"]["naam1"]; // Change recipient to a field value in the new record 
		 $Email->Subject = "Opgave"; // Change subject
		$value = ew_ExecuteScalar("SELECT naam2 FROM view1");
		 $Email->Content = "\nBeste ".$Args["rsnew"]["naam1"].",<br><br>
		 
		 Bedankt voor je opgave.<br>
		 Ik kom naam2: ".$value."<br>
		 Je opgegeven gegevens zijn als volgt:<br>
		 Graag ontvangen we 1 week voor de activiteit je betaling op bankrekening NL52 INGB 0000 6517 00 t.n.v. conferentiecontact Calvijn.<br><br>
Groeten en tot het aanstaande weekend,<br>
Jose van Duinen</body></html>";
	}
	 return TRUE;
 }