Custom Field of Date and setting it to populate sysdate?

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
don_moats
Posts: 3
Joined: 24 Oct 2005, 18:02

Custom Field of Date and setting it to populate sysdate?

Post 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
ppatel
Posts: 8
Joined: 12 May 2022, 16:22

Re: Custom Field of Date and setting it to populate sysdate?

Post by ppatel »

Replying to this post because this is also something I am looking to implement.. any ideas anyone?
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Custom Field of Date and setting it to populate sysdate?

Post by cas »

you can use the option of custom override functions as described in the admin manual
ppatel
Posts: 8
Joined: 12 May 2022, 16:22

Re: Custom Field of Date and setting it to populate sysdate?

Post 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?
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Custom Field of Date and setting it to populate sysdate?

Post by cas »

Function needs to be called differently, check admin guide page 88/89
ppatel
Posts: 8
Joined: 12 May 2022, 16:22

Re: Custom Field of Date and setting it to populate sysdate?

Post by ppatel »

Is the function not written correctly or does it have to be called differently in Manage Custom Fields?
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Custom Field of Date and setting it to populate sysdate?

Post by cas »

please read the manual chapter 7 in the admin guide about custom functions.
ppatel
Posts: 8
Joined: 12 May 2022, 16:22

Re: Custom Field of Date and setting it to populate sysdate?

Post 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? :?
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Custom Field of Date and setting it to populate sysdate?

Post 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
Post Reply