Page 1 of 1
Email_Sending - $args["rsnew"]
Posted: Thu Aug 04, 2022 1:08 am
by mpol_ch
Hi,
I am using the following code to send email.
But it is sending email even when I do not change/update the condition fields such Status, Prio and Anonym.
I do not want to receive email when I change another field than the condition fields.
It should check the condition for email if one of this condition field has been updated.
How to reach this?
if ((CurrentPageID() == "edit") AND (($args["rsnew"]["Status"] == 9) OR (($args["rsnew"]["Prio"] == "Eilig") AND ($args["rsnew"]["Anonym"] == 1 )))) { // If Add page
//$email->Recipient = $args["rsnew"]["MyEmailField"]; // Change recipient to a field value in the new record
$email->Recipient = $this->Bearbeiter->CurrentValue;
$email->Subject = "4In Sachen " .$args["rsnew"]["GNr"]; // Change subject
$email->Content = "<p>Fall mit GNr: ".$args["rsnew"]["GNr"]. " zwischen den Parteien " .$args["rsnew"]["Parteien"]. " wurde aktualisiert</p>"; // Append additional content
$email->Content .= "<p>VS: ".$args["rsnew"]["Vs"]. " Gs: " .$args["rsnew"]["Gs"]."</p>"; // Append additional content
}
mpol_ch
Re: Email_Sending: $args[rsnew][]
Posted: Thu Aug 04, 2022 2:57 am
by yusufnalbantoglu
Hi,
It doesn't work because you built the conditional structure on rsnew. You can stop sending mail by checking whether the new data (rsnew) is the same as the old data (rsold).
if ((CurrentPageID() == "edit") AND (($args["rsnew"]["Status"] != $args["rsold"]["Status"] && $args["rsnew"]["Status"] == 9) OR (($args["rsnew"]["Prio"] != $args["rsold"]["Prio"] && $args["rsnew"]["Prio"] == "Eilig") AND ($args["rsnew"]["Anonym"] != $args["rsold"]["Anonym"] && $args["rsnew"]["Anonym"] == 1 )))) {
Re: Email_Sending: $args[rsnew][]
Posted: Thu Aug 04, 2022 8:22 am
by mobhar
How about this code?
if ((CurrentPageID() == "edit") AND (($args["rsnew"]["Status"] == 9) OR (($args["rsnew"]["Prio"] == "Eilig") AND ($args["rsnew"]["Anonym"] == 1 )))) { // If Edit page
//$email->Recipient = $args["rsnew"]["MyEmailField"]; // Change recipient to a field value in the new record
$email->Recipient = $this->Bearbeiter->CurrentValue;
$email->Subject = "4In Sachen " .$args["rsnew"]["GNr"]; // Change subject
$email->Content = "<p>Fall mit GNr: ".$args["rsnew"]["GNr"]. " zwischen den Parteien " .$args["rsnew"]["Parteien"]. " wurde aktualisiert</p>"; // Append additional content
$email->Content .= "<p>VS: ".$args["rsnew"]["Vs"]. " Gs: " .$args["rsnew"]["Gs"]."</p>"; // Append additional content
} else {
return false;
}
Re: Email_Sending - $args["rsnew"]
Posted: Thu Aug 04, 2022 7:37 pm
by mpol_ch
Hi,
to add else condition stop to send any email.
Do you know can I check if a field has been updated by las edit?
For the edit I am having 4x if conditions and sometimes three of them a true.
Then the system should send 3 emails for each matched condition.
Is that possible with if?
Or do I need something like loop?
mpol_ch
Re: Email_Sending - $args["rsnew"]
Posted: Fri Aug 05, 2022 8:35 am
by mobhar
Make sure you do not remove return true;
line at the end of Email_Sending server event.