Page 1 of 1
Custom Field of Date and setting it to populate sysdate?
Posted: 04 Nov 2005, 22:22
by don_moats
If I created a custom field (ie Close Date) and have it required when bug is Closed, how do I set auto-populate a default value of sysdate when the status is changed to Closed and a user is not able to modify this value?
Thanks
Versions:
Windows 2K
Mantis 1.0.0rc2
MySQL Server 4.1.14
Apache v2.0.55
PHP 4.4.0
Re: Custom Field of Date and setting it to populate sysdate?
Posted: 16 May 2022, 15:59
by ppatel
Replying to this post because this is also something I am looking to implement.. any ideas anyone?
Re: Custom Field of Date and setting it to populate sysdate?
Posted: 17 May 2022, 06:56
by cas
you can use the option of custom override functions as described in the admin manual
Re: Custom Field of Date and setting it to populate sysdate?
Posted: 23 May 2022, 17:21
by ppatel
I have added a function in my core\custom_function_api.php file like below:
function custom_function_default_string_closed() {
$date = date('Y-m-d H:i:s');
return $date;
}
In accordance with the other custom functions, I believe adding "=closed" in the possible values field of the custom field will cause the custom field to use this function. However, I am still seeing the field as blank. Any ideas?
Re: Custom Field of Date and setting it to populate sysdate?
Posted: 23 May 2022, 21:43
by cas
Function needs to be called differently, check admin guide page 88/89
Re: Custom Field of Date and setting it to populate sysdate?
Posted: 23 Sep 2022, 12:58
by ppatel
Is the function not written correctly or does it have to be called differently in Manage Custom Fields?
Re: Custom Field of Date and setting it to populate sysdate?
Posted: 23 Sep 2022, 14:25
by cas
please read the manual chapter 7 in the admin guide about custom functions.
Re: Custom Field of Date and setting it to populate sysdate?
Posted: 27 Sep 2022, 19:06
by ppatel
In config/custom_functions_inc.php:
function custom_function_override_string_DateClosed($p_bug_id) {
$t_id = custom_field_get_id_from_name('DateClosed');
$date = date('Y-m-d H:i:s');
custom_field_set_value($t_id, $p_bug_id, 'Test', $p_log_insert = false);
}
Am I getting closer?

Re: Custom Field of Date and setting it to populate sysdate?
Posted: 28 Sep 2022, 07:00
by cas
these overrides are only called if the corresponding function exists in core/custom_function_api.php so in case there exists a custom_function_default_string_DateClosed fuction this will work.
Otherwise you most likely need a plugin