Results 1 to 3 of 3

Thread: How to create a new field in the same table instead of _cstm through module loader

  1. #1
    archian is offline Member
    Join Date
    Feb 2007
    Posts
    5

    Default How to create a new field in the same table instead of _cstm through module loader

    Hi,

    I am trying to add a field to the existing database table while installing through Module loader. With custom_fields been provided in manifest.php, this creates a new table with _cstm and adds the corresponding fields to the newly created _cstm table.

    Will it be possible for me to add a field to the existing table itself instead of creating a _cstm table and adding the new field? If possible, could you please let me know what is the syntax for providing in the manifest.php?

    Thanks,
    -Rajesh

  2. #2
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: How to create a new field in the same table instead of _cstm through module loader

    This is generally not recommended as the _cstm table is exactly for this purpose. It ensures that your custom fields will live as the product is updated. However, if you really would like to do this set up a vardefs file with the new field(s) and define the vardef in the manifest file like:
    PHP Code:
    'vardefs' => array(
        array(
    'from'=> '<basepath>/vardefs/modules/MYMODULE/MYMODULE-vardefs.php',
             
    'to_module'=> 'MYMODULE',
        ),
    ), 
    And in the MYMODULE-vardefs.php file:
    PHP Code:
    $dictionary['MYMODULE']['fields'] = array_merge ($dictionary['MYMODULE']['fields'],
    array(
        
    'MYFIELD'=>
      array (
        
    'name' => 'MYFIELD',
        
    'vname' => 'LBL_MYFIELD',
        
    'type' => 'char',
        
    'len'=>155,
      ),
    )
    ); 
    Or optionally add the necessary SQL statements to a pre_install script to create the field. The forums have more examples for both.

  3. #3
    andydreisch's Avatar
    andydreisch is offline Sugar Team Member
    Join Date
    Apr 2005
    Location
    San Jose
    Posts
    2,080

    Default Re: How to create a new field in the same table instead of _cstm through module loade

    Hi archian, further to eggsurplus's comments, which are spot on, my question is ... why do you feel compelled to make this change in this way? Can you describe what you perceive as the pros/cons of incorporating the field in a base table?

    Thanks,

    Andy
    Andy Dreisch
    Vice President, Online Team


    Check out our Podcasts!
    Sugar University for training
    Sugar Wiki for developer and user help
    SugarForge for modules, themes, lang packs
    SugarExchange for production-ready extensions
    Enter/view bugs via the Sugar bug tracker

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. HELP - Act import (field mapping)
    By smelamed in forum Help
    Replies: 32
    Last Post: 2010-12-15, 05:39 PM
  2. problemi step 6 di SugarSuite-Full-4.0.1h
    By lucia in forum Italiano
    Replies: 0
    Last Post: 2006-12-27, 08:50 AM
  3. Replies: 1
    Last Post: 2006-09-11, 03:38 PM
  4. Fatal error: Max
    By spokes2k4 in forum Help
    Replies: 3
    Last Post: 2006-01-15, 03:50 PM
  5. Empty config.php at the end of install
    By aemadrid in forum Help
    Replies: 2
    Last Post: 2005-08-01, 06:29 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
  •