I am running the latest 2020vMy issue is that I am trying to edit the contents of an email sent when a record is added.
As of right now this is the content of the email that gets sent:Record status changed as follows:
Table: ChangMGMT
Key value: 8
Action: Inserted
Under the Server Events->Table-Specific->Common->Email_Sending I added the following code:function Email_Sending($email, &$args) {
if (CurrentPageID() == "add") { // If Add page
$Email->Subject = "Network Change Management System (New change expecting approval)"; // Change subject
$Email->Format = "HTML";
$Email->Content = " ";
$Email->Content .= "Hello,<br> <br/><p>A new change has been added to the NCMS (Network Change Managment System.)</p>";
$Email->Content = "<br><p><Please, login and approve so the change can be implemented!</p>";
}
return TRUE;
}
BUT I keep receiving the email default format. Why isn’t the change taking effect?Can anyone help me with this?
I corrected that and I am still experiencing the same issue.Here is my new crypt:// Email Sending event
function Email_Sending(&$email, &$Args) {// add
if (CurrentPageID() == “add”) {
$email->Subject = “A new Change has been submitted!”;
$email->Content = “Hello network team,”;
$email->Content .= “
Please, login into the system and approve so the change can be implemented!”;
$email->Content .= “
Network Change approved by: ” . CurrentUserName().“”;
}//var_dump($email); var_dump($Args); exit();
return TRUE;
}Is there another setting somewhere else that I am not aware of? My emails continue to be the default as follows:Record status changed as follows:
Table: ChangMGMT
Key value: 9
Action: Updated
This has been working great. However, I would like to reduce the amount of email we get. I wish there was a way that, under the “edit” clause, would send the email only if certain record is updated.
For example, I have a record in my table called “Aproval”. I only want to receive email if this record gets changed. How can this be acomplished?
Here is my script:
function Email_Sending(&$email, &$Args) {
// edit
if (CurrentPageID() == “edit”) {
$email->Subject = “Network Change Status has changed!”;
$email->Content = “
Hello network team,
”;
$email->Content .= “
This email is to let you know that your network change request status has changed.”;
$email->Content .= “
I tried that with the following and apparently there is a syntax error as the page is not showing.
Here is how I adjusted:
if (CurrentPageID() == “edit” && $Args[“rsnew”][“Approval”] < 0) because Approval can be 0 (pending), 1 (reviewed) and 2 (approved). I would like to send emails when the Approval changes to anything other than 0.
Here is the issue… The emails, with a modified subject and body are not sent when the conditions are matched (which is what I wanted) but another default email is sent from the scripts that indicate there was a record edited.
Here is the email that gets sent when the conditions are not matched:
Record status changed as follows:
Table: ChangMGMT
Key value: 41
Action: Updated
When you enable either for “On Add”, “On Edit”, and/or “On Delete” below “Email Notification” from Table setup, then by default system will always send email.
So, you need to add “else” condition in “Email_Sending” server event to customize the Subject and/or the Content of email that suits your needs, too.