Custom function for set value in a custom field

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
pollevr
Posts: 28
Joined: 25 Jun 2020, 15:12

Custom function for set value in a custom field

Post by pollevr »

Hi all,

in Mantis 2.24.1 I'm trying to write a custom function for setting value automatically in a custom field when an issue is updated.

In /config/custom_functions_inc.php I wrote:

Code: Select all

function custom_function_override_issue_update_validate( $p_issue_id, $p_bug_data, $p_bugnote_text ) {
  $t_id = custom_field_get_id_from_name( '<my_custom_field_name>' );

  custom_field_set_value( $t_id, $p_issue_id, 'any_custom_value', $p_log_insert = false);
}
Why not set value in my custom field?

Thanks to all.
Cristian
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Custom function for set value in a custom field

Post by atrol »

I didn't check why it doesn't work, because using this custom function is no good way to implement what you want.
The function is meant to validate data, it's not meant to change data.

Keep also in mind, that custom functions are deprecated and might be removed in future MantisBT versions.

The right way would be to write a plugin that uses event EVENT_UPDATE_BUG_DATA.
Please use Search before posting and read the Manual
pollevr
Posts: 28
Joined: 25 Jun 2020, 15:12

Re: Custom function for set value in a custom field

Post by pollevr »

Hi atrol,

thank you for your suggestion, so I'll try to write a custom plugin, but I created an other issue because I don't understand why I can't build my custom plugin, so if you have time, have a look to my other issue please (https://www.mantisbt.org/forums/viewtop ... =3&t=27025) :)

Bye,
Cristian
pollevr
Posts: 28
Joined: 25 Jun 2020, 15:12

Re: Custom function for set value in a custom field

Post by pollevr »

Hi atrol,

I found that this event is not for me:
atrol wrote: 28 Jun 2020, 20:47 The right way would be to write a plugin that uses event EVENT_UPDATE_BUG_DATA
but it's better use EVENT_UPDATE_BUG for manipulating and calculating a custom field value on updating issue.

Anyhow, I can't build my custom plugin succesfully for my need.

I can't understand why the event doesn't work (see https://www.mantisbt.org/forums/viewtop ... =3&t=27029).

Thank you,
Cristian
Post Reply