Hello. I'm new in PHPMaker so I will consult to the masters if how to update database when my ViewValue in List Page Change or update?
Where Event should I put my script?
Thanks a lot.
Hello. I'm new in PHPMaker so I will consult to the masters if how to update database when my ViewValue in List Page Change or update?
Where Event should I put my script?
Thanks a lot.
I have this code and I put it in Row_Rendered server event and it works, it triggers when the current date change and the result displays on hdAge Field View Value.
But in this case I want also to update mysql database once the view value of the hdAge Field change.
// Row Rendered event
function Row_Rendered() {
// To view properties of field class, use:
//var_dump($this-><FieldName>);
$d1 = date ('m/d/Y H:i:s');
$d2 = $this->DateReported->CurrentValue;
$now = strtotime($d1);
$your_date = strtotime ($d2);
$status = $this->TicketStateID->CurrentValue;
if ($status == '3') {
} else {
$datediff = $now - $your_date;
$d3 = floor($datediff/3600);
if ($d3 <= "0") {
$this->hdAge->ViewValue = "0";
} else {
$this->hdAge->ViewValue = $d3;
}
}
ew_Exceute("UPDATE YourTable SET YourField = xxx WHERE YourPrimaryKeyField = " . $this->YourPrimaryKeyField->CurrentValue); // Assume your primary key field is number here so no need to quote
Thanks it helps my issue.
Last question in List page, is it also possible to send an email in "List" page when viewvalue change because in Email_Sending it has no "List" page it has "add", "edit" and "view" only. Where I can put my code to send email automatically when Value change without editing the row.
Thanks a lot.
You can send email when you use Email class. Add this line before you set your recipient and content:
$Email = new cEmail();
And add after your email content:
$Email->Send(); // to send
It depends where you put the code to change the ViewValue. The code can add after your update statement as you have checked the ViewValue change.