PHPMaker v2024.15
Can anyone figure out what's wrong with my script? It works if I only select one record (for example I select the first record), it will fail if I select multiple record to update. On debug, it failed on the first record and rollback. if I only select this particular record, it can update.
function Page_Load()
{
//Log("Page Load");
$this->CustomActions["ForceClose"] = new ListAction("ForceClose", "Force Close", IsLoggedIn(), ACTION_POSTBACK, ACTION_MULTIPLE, "Force Close?", "", "All selected PCBA force closed.");
}
function Row_CustomAction($action, $row)
{
// Return false to abort
EventLog("Action=".$action);
EventLog("ID=".$row["ID"]);
if ($action == "ForceClose") { // Check action name
$pcbastatus = "4";
$currentuserid = CurrentUserID();
$updatedat = date("Y-m-d H:i:s");
$versioning = $row["VERSIONING"]+1;
$rsnew = ["PCBA_STATUS" => $pcbastatus, "UPDATED_BY" => $currentuserid, "UPDATED_AT" => $updatedat,"VERSIONING" => $versioning]; // Array of field(s) to be updated
$result = $this->update($rsnew, ["ID" => $row["ID"]]); // Update the current record only (the second argument is WHERE clause for UPDATE
if (!$result) { // Failure
$this->setFailureMessage("Failed to force close selected PCBA!");
return FALSE; // Abort and rollback
} elseif ($this->SelectedIndex == $this->SelectedCount) { // Last row
$this->setSuccessMessage("Selected PCBA has been Force Closed!");
return TRUE; // Success
}
}
//return true;
}