[Vtigercrm-developers] datetime customfield in potentials

Jose Luis Ocaranza jlocaranza at easyclick.com.ar
Mon Feb 10 18:59:08 GMT 2014


Hi all,

I'm trying to add following functionality:
when a potential change the sale stage, i want to save the datetime the
potential enter that stage in a datetime field.
ie: 'Needs Analysis Scheduled ' => 'NeedsAnalysisScheduledDate'

I'm creating them using vtlib and it creates them in vtiger_potential not
vtiger_potentialcf (maybe i'm missing something here).
Then i changed DetailViewAjax.php and Save.php to handle the update of this
new fields when a potential is saved, but i'm having this problems:

1- The datetime is saved OK in the database field, but is not showing up in
the detailview of the potential.

2- If a field, ie: NeedsAnalysisScheduledDate, has value, when I change the
stage to, ie:'Proposal Presented', the field "ProposalPresentedDate" is
updated OK but the first changes to "null", i need to keep all the data of
the 4 datetime fields.

the code to handle the change in Save.php (in DetailViewAjax.php is
similar) is:

$sale_stage_date = str_replace(" ", "", $_REQUEST['sales_stage']) . "Date";
if (array_key_exists($sale_stage_date, $focus->column_fields)) {
  $focus->column_fields[$sale_stage_date] = date('Y-m-d H:i:s');
}
$focus->save("Potentials");

I also tried to get the same functionality using workflows, but if I not
mistaken, the workflows only works once the data has been saved ("save to
db" -> "run workflow"), then I can't access to the "old" value of a field
and do something with it before saving the the record, right?.

Thanks in advance for any idea or help,


-- 
Jose Luis Ocaranza
Argentina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20140210/236fef92/attachment.html>


More information about the vtigercrm-developers mailing list