Change Value of Custom Field in Plugin

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
bluescreenterror
Posts: 20
Joined: 16 Jan 2020, 11:19

Change Value of Custom Field in Plugin

Post by bluescreenterror »

Hi,

I started to write a little plugin which change the value of a custom field (enumeration) when the status is set to resolved.

I got the basic of the plugin and use a hook on the "EVENT_UPDATE_BUG_DATA" event.
Here is my code for the function which is triggered by the hook:

Code: Select all

function bugUpdated($p_issue_id, $p_bug_data, $p_bugnote_text)
    {
	if( $p_bug_data->status == RESOLVED )
	{
	$t_id = custom_field_get_id_from_name('KanBan.Status');
	#$p_bug_data->KanBan.Status = "Ready";	
	#custom_field_set_value( $t_id , $p_issue_id, 'Ready'); 
	}
	return $p_bug_data;
    }
I tryed to use the custom_field_set_value() method to set the value but without effect. I assume I have to manipulate my custom field in the $p_bug_data directly but I dont know how.
Mantis: 2.23.0
XAMPP: v.3.2.4
PHP Version: 7.1.33
Windows Server 2016
bluescreenterror
Posts: 20
Joined: 16 Jan 2020, 11:19

Re: Change Value of Custom Field in Plugin

Post by bluescreenterror »

Ah..I got the solution...the wrong Event to manipulate Custom fields you have to go for the "EVENT_UPDATE_BUG" which is triggered later on bug_update.php
Mantis: 2.23.0
XAMPP: v.3.2.4
PHP Version: 7.1.33
Windows Server 2016
Post Reply