Execute SQL command after create issue

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
mpa
Posts: 27
Joined: 15 Jan 2008, 12:34

Execute SQL command after create issue

Post by mpa »

Hi,

I need to update a custom_field (26) automatically after creating of an issue.
The data (name) is coming from a separate table 'DATA_table'.

I have created a new file 'custom_functions_inc.php' and located this file in the config folder.
Within the file i created an 'override' function, see below;

Code: Select all

function custom_function_override_issue_create_notify( $p_issue_id ) {
	$t_custom_field = 26;

	db_param_push();
	$t_query = 'SELECT `c`.`name`
				FROM {bug} AS b
				JOIN `DATA_table` AS c ON `b`.`category_id` = `c`.`category_id`
				WHERE `b`.`id` = ' . $p_issue_id . '';
	
	$t_result = db_query( $t_query );
	
	db_param_push();
	$t_query2 = 'INSERT INTO {custom_field_string} 
					(`field_id`,`bug_id`,`value`)
				VALUES
					( ' . $t_custom_field . ',' . $p_issue_id . ',' . $t_result .')';
					
	}
What im i doing wrong here? It doesn't seems to work at the moment. Or the function is not triggered?

Thanks for helping....
cas
Posts: 1587
Joined: 11 Mar 2006, 16:08
Contact:

Re: Execute SQL command after create issue

Post by cas »

if you want to be sure the code is executed, simply add the following command ad the end of the function:
echo $t_query;
echo "<br>":
echt $t_query2;
echo "<br>":
die("execution");

If nothing happens, you know it is not executed, otherwise you also see the actual SQL statements that have been executed.
This way (assuming you do have a test environment) you will your problem soon enough :mrgreen:
mpa
Posts: 27
Joined: 15 Jan 2008, 12:34

Re: Execute SQL command after create issue

Post by mpa »

Thank you Cas,

It did help me find the problem.


I needed to add:
db_query( $t_query );

Thanks again!
Post Reply