Results 1 to 5 of 5

Thread: Add datatype date/time

  1. #1
    dvelguru is offline Senior Member
    Join Date
    Nov 2009
    Posts
    42

    Cool Add datatype date/time

    I noticed the datatype is used for the date_start of scheduling activities ...

    When using editviewdefs.php type => datetimecombo my date/time does not save even after I converted the datatype of a field in DB to DATE/TIME.



    So I will have to modify save() to do this.

    Maybe this is available and I just don't know how to do it. But I don't think so as there are no date/time data type options when adding fields to a module.

  2. #2
    dvelguru is offline Senior Member
    Join Date
    Nov 2009
    Posts
    42

    Default Re: Add datatype date/time

    Alright, I can definitely see why it would be a hassle to have a feature like this.

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

    Default Re: Add datatype date/time

    Hi dvelguru,

    You can't add a datetime field through studio, but you can add it as an extension.

    I added a datetime field called note_date to the Notes module so that I could set the date something occurred as distinct from the date the record was created or modified.

    To do this I added a new file with the path:

    <sugarcrm>/custom/Extension/modules/Notes/Ext/Vardefs/custom_fields.php

    whose entire contents is:

    PHP Code:
    <?php
      $dictionary
    ['Note']['fields']['note_date'] = array(
            
    'required'      => '1',
            
    'name'          => 'note_date',
            
    'alias'         => 'hist_date',
            
    'vname'         => 'LBL_NOTE_DATE',
            
    'type'          => 'datetime',
            
    'default'       => date("m/d/Y H:i"),
            
    'massupdate'    => '0',
            
    'importable'    => 'true',
            
    'reportable'    => '1'
      
    );
    ?>
    The name of the file does not matter. Do a repair and the new field appears in the main notes table (not notes_cstm). You can then add it to layouts, etc through Studio.

    The only additional problem was that the time inputs would not appear in the QuickCreate layout when I added my note_date field to Quick Create layout through Studio. To fix this I had to define the type in <sugarcrm>/custom/modules/metadata/quickcreatedefs.php with the line:

    'type' => 'datetimecombo',

    Phil

  4. #4
    grasshopper is offline Junior Member
    Join Date
    Jan 2010
    Posts
    2

    Default Re: Add datatype date/time

    how come when I save a new record the stored datetime is 00/00/00 00:00:00? how do i save the input selected by the user or the value the controls have been set?

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

    Default Re: Add datatype date/time

    It should save it correctly. If you set it in the UI, it should save that value. If you do not set it, it will set it to the default value defined in studio/vardefs.

    If you did not set a default value and left it blank in Edit view, it might save it as all 0's. What I've seen in this case is that it then gets displayed as 1/1/2000 in Detail View. Go into studio and check how the default is set.

    Also, did you define the fields using a vardefs extension or by adding a new field through studio?

    Phil

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Date/Time field
    By monicaDC in forum Developer Help
    Replies: 6
    Last Post: 2010-01-13, 04:36 PM
  2. Convert Date-Time into just Date
    By FishGuts in forum Help
    Replies: 0
    Last Post: 2009-05-30, 01:02 AM
  3. Custom field with 'date' datatype not saved
    By Christoph in forum Help
    Replies: 0
    Last Post: 2005-07-12, 02:53 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
  •