Translations of this page:

Assign the issue to the user selected within the form and update History table

For basic information on plugins, please refer: Infocapture plugins

In this section we would see how to assign the issue to the user selected within the form and accordingly update the History table

Here is the xml file of the form: download

Lets suppose we have this test project with ID = 17

To achive this we would require plugin_17_add_issue.php

<?php
 
function hd_plugin_17_add_issue($params)
{
	global $db;
	$project_info = $params["project"];
	$issue_info = $params["issue"];
	$issue_fields = $params["issue"]["fields_values"];
 
	//$user_id is the id of the reporter, which is "0" (ie. default reporter) if no other user is selected 
	$user_id = $issue_fields["assign_to"];
	if ($user_id == 0)
		return NULL;
 
	$result["issue"] = array();
	$result["issue"]["assigned"] = $user_id;
	
	// 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);
	
	return $result;
			   
}
?>

Place the above file in folder: /httpdocs/intranet/infocapture/plugins

Select the user from the select list box and report the issue

The issue is now assigned to the selected user “Claromentis Administrator”. History table is updated with the Assigned field entry

 
help/infocapture/plugins/assign_issue_to_user_selected_in_form.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