Email_Sending - $args["rsnew"]

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mpol_ch
User
Posts: 877
Location: Switzerland

Email_Sending - $args["rsnew"]

Post 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


yusufnalbantoglu
User
Posts: 12

Post 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 )))) {


mobhar
User
Posts: 11660

Post 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;
}

mpol_ch
User
Posts: 877
Location: Switzerland

Post 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


mobhar
User
Posts: 11660

Post by mobhar »

Make sure you do not remove return true; line at the end of Email_Sending server event.


Post Reply