Translations of this page:

Update History table on execution of plugins

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> =&gt; <a href="../people/viewprofile.php?id=' . $user_id . '">' . $name . '</a>'
			);
	$queryinsert = new QueryInsert("hd_issue_history", $history);
	$db->query($queryinsert);

?>
 
help/infocapture/plugins/update_history_table_on_plugin_execution.txt · Last modified: 07/06/2011 04:49 by sweta
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki