HI all.Have moved over to 2025 and am having an issue with an old email sending code.in the server events and client scripts the following code is shown.
function Email_Sending($email, $args) {
// var_dump($email, $args);
// exit();
if (CurrentPageID() == "add") { // If Add page
$email->Recipient = $args["rsnew"]["MyEmailField"]; // Change recipient to a field value in the new record
$email->Subject = "My New Subject"; // Change subject
$email->Content .= "<p>Added by " . CurrentUserName() . "</p>"; // Append additional content
}
return true;
}
How has the version change to $oldRow and $newRow affected the above? Is it now as below:
function Email_Sending($email, $args) {
// var_dump($email, $args);
// exit();
if (CurrentPageID() == "add") { // If Add page
$email->Recipient = $args["newRow"]["MyEmailField"]; // Change recipient to a field value in the new record
$email->Subject = "My New Subject"; // Change subject
$email->Content .= "<p>Added by " . CurrentUserName() . "</p>"; // Append additional content
}
return true;
}
Hello all.Here is my working code in version 2025
// email Sending event
public function emailSending($email, &$args) {
//var_dump($email); var_dump($args); exit();
if (CurrentPageID() == "edit") {
//Get email address - This has to be placed into the Header under email reciepient
$REC_ADD = ExecuteScalar("SELECT users_email FROM userview WHERE idusers =". $args["new"]["staff_member"]."");
//Get Client Name
$WC_CODE = ExecuteScalar("SELECT client_name FROM master_client WHERE wc_code =". $args["new"]["client"]."");
//Get Catergory
$catergory = ExecuteScalar("SELECT tax_type FROM job_tax_type WHERE pk =". $args["new"]["tax_type"]."");
//get partners Email
if ($args["new"]["email_partner"] == '1' AND $args["new"]["email_staff"] == '1'){
$email1 = ExecuteScalar("SELECT users_email FROM userview WHERE idusers =". $args["new"]["partner"]."");
$email2 = ExecuteScalar("SELECT users_email FROM userview WHERE idusers =". $args["new"]["staff_member"]."");
$email3 = $email1.';'.$email2;
}
elseif ($args["new"]["email_partner"] == '2' AND $args["new"]["email_staff"] == '1'){
$email3 = ExecuteScalar("SELECT users_email FROM userview WHERE idusers =". $args["new"]["staff_member"]."");
}
elseif ($args["new"]["email_partner"] == '1' AND $args["new"]["email_staff"] == '2'){
$email3 = ExecuteScalar("SELECT users_email FROM userview WHERE idusers =". $args["new"]["partner"]."");
}else {
$email3 = "xxx@xxxxx.net";
}
//Get Urgency
$URG = ExecuteScalar("SELECT severity FROM job_Severity WHERE pk =". $args["new"]["severity"]."");
//Get Job Number
$job1 = $args["old"]["job_number"];
//Get Task Heading
$head1 = $args["new"]["heading"];
//email Header
$email->Recipient = $email3; // Change recipient to a field value in the new record
$email->Subject = "Update of Job number: " .$job1." - " .$WC_CODE." - " .$head1."" ; // Change subject
$newmail = new Email;
//email Body
$email->Content = "<BR><BR><BR><table border='1'>
<tbody>
<tr>
<td><b>Client:</b></td>
<td>".$WC_CODE."</td>
</tr>
<tr>
<td><b>Title:</b></td>
<td>". $args["new"]["heading"]."</td>
</tr>
<tr>
<td><b>Catergory:</b></td>
<td>".$catergory."</td>
</tr>
<tr>
<td><b>Severity:</b></td>
<td>".$URG."</td>
</tr>
<tr>
<td><b>Job issue:</b></td>
<td>". $args["new"]["issue"]."</td>
</tr>
<tr>
<td><b>Job notes:</b></td>
<td>". $args["new"]["notes"]."</td>
</tr>
<tr>
<td><b>Job outcome:</b></td>
<td>". $args["new"]["outcome"]."</td>
</tr>
<tr>
<td><b>Added By:</b></td>
<td>". CurrentUserName ()."</td>
</tr>
</tbody>
</table>";
}
return TRUE;
}