Results 1 to 4 of 4

Thread: need custom field to be type datetime

  1. #1
    mocetech is offline Junior Member
    Join Date
    Nov 2009
    Posts
    2

    Default need custom field to be type datetime

    Hi, I'm kinda new to sugarcrm. I'm already created a custom field in the opportunities module that is type date. I changed the type in the datebase to be of datetime. I have a separate php link that insert a current date time when the user is ready to close the opportunity. The user can not edit this field because I didn't add it to the edit view. However it is in the detail view but it does not show the time just the date.

    The problem is that when the user has already closed the opportunity but re-edit the opportunity to add new information, sugarcrm updates my custom field to have 00:00:00 for the time.

    How can I make sugarcrm know my custom field is a datetime instead of date type?

    Thank you all in advance.

    Tony
    sugarcrm Version 5.2.0k (Build 5837)

  2. #2
    salesagility's Avatar
    salesagility is offline Sugar Community Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    2,379

  3. #3
    blitz2190 is offline Senior Member
    Join Date
    Jul 2009
    Posts
    105

    Default Re: need custom field to be type datetime

    im not sure but i think you need to set the type to datetime or date timecombo in the fields_meta_data table for that field so that sugar recognizes it as that type of field, then repair/rebuild.

  4. #4
    datasponge is offline Sugar Community Member
    Join Date
    Mar 2008
    Location
    San Jose, CA, USA
    Posts
    553

    Default Re: need custom field to be type datetime

    Simplest solution is to use Enhanced Studio to create it as salesagility suggested.

    Or you can create a vardefs extension to define a new field by simply creating two small files.

    To create an extension, just create two new files: one for the field vardefs definition under <sugar_root>/custom/Extension/modules/Opportunities/Ext/Vardefs like custom.php and one for the label definition under <sugar_root>/custom/Extension/modules/Opportunities/Ext/Language like en_us.custom.lang.php

    For example, the contents below define the field 'note_date' in my Notes module:

    PHP Code:
    <?php
      $dictionary
    ['Note']['fields']['note_date'] = array(
        
    'required'     => '1',
        
    'name'        => 'note_date',
        
    'alias'        => 'hist_date',
        
    'vname'        => 'LBL_NOTE_DATE',
        
    'type'        => 'datetime',
        
    'massupdate'    => '0',
        
    'importable'    => 'true',
        
    'reportable'    => '1'
      
    );
    ?>
    You should change the first array element from 'Note' to 'Opportunity'. You should also change the name to what you want and the vname to the name of a label (which also must be defined). You can change any of the other array elements like 'required' or 'reportable' to what you want.

    The label file would contain something like:
    PHP Code:
    <?php
    $mod_strings
    'LBL_NOTE_DATE'] => 'Activity Date';
    ?>
    When you finish the file, go to Admin and do a Quick Repair and Rebuild and you'll have your new field.

    Phil

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Custom Datetime field in Meetings
    By Mithun in forum Developer Help
    Replies: 7
    Last Post: 2010-09-17, 11:49 AM
  2. DateTime Custom Field ?
    By spencer134 in forum Help
    Replies: 3
    Last Post: 2010-01-28, 07:20 PM
  3. Datetime and Time date type in custom fields
    By wyred in forum Feature Requests
    Replies: 1
    Last Post: 2009-02-16, 06:13 AM
  4. need help to create custom datetime data type
    By sslhbala82 in forum Developer Help
    Replies: 0
    Last Post: 2008-06-20, 03:07 PM
  5. Field of Type datetime (in a custom module of Sugar 5)
    By wkamdem in forum General Discussion
    Replies: 2
    Last Post: 2008-03-27, 03:44 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •