When we change the value of special fields like “Reported by, Assigned” through plugin, they are not recorded in the History table. To update History table with such changes, use following code in your plugin:
<?php
// Create a date
$insertDate = new Date();
// Create a user
$user = new User($user_id);
$user->Load();
$name = $user->GetFirstname() . ' ' . $user->GetSurname();
$history = array(
"int:issue_id" => $params['issue']['id'],
"int:date1" => $insertDate->getDate(DATE_FORMAT_TIMESTAMP),
"int:user_id" => $user_id,
"str:field" => '@str(helpdesk.assigned_to, Assigned_to)',
"str:field_symname" => '_assigned_',
"str:changes" => '<a href="../people/viewprofile.php?id=0"></a> => <a href="../people/viewprofile.php?id=' . $user_id . '">' . $name . '</a>'
);
$queryinsert = new QueryInsert("hd_issue_history", $history);
$db->query($queryinsert);
?>
Discussion