Results 1 to 8 of 8

Thread: custom vardefs.php does not work

  1. #1
    amicky is offline Member
    Join Date
    Oct 2008
    Posts
    12

    Default custom vardefs.php does not work

    Hi,

    My probleme is the following:

    I want to add a new fied to Users module.
    I tried to do that by creating a custom vardefs.php in custom/modules/Users/vardefs.php (i copied the file from modules/Users/vardefs.php).

    in my custom/modules/Users/vardefs.php i added my new field definition this way:

    Code:
    $dictionary['User'] = array(
        'table' => 'users',
        'audited' => true,
        'fields' => array(
            'id' => array(
                'name' => 'id',
                'vname' => 'LBL_ID',
                'type' => 'id',
                'required' => true,
            ) ,
            'user_name' => array(
                'name' => 'user_name',
                'vname' => 'LBL_USER_NAME',
                'type' => 'user_name',
                'dbType' => 'varchar',
                'len' => '60',
                'importable' => 'required',
            ) ,
            'user_hash' => array(
                'name' => 'user_hash',
                'vname' => 'LBL_USER_HASH',
                'type' => 'varchar',
                'len' => '32',
                'reportable' => false,
                'importable' => 'false',
            ) ,
    
        ...
        //NEW FIELD DEFINITION
         'new_field'=> array(
                'name' => 'new_field',
                'vname' => 'LBL_NEW_FIELD',
                'type' => 'varchar',
                'len' => '5',
            ) ,
    
    ...
    After defining the new field, i ran <<Quick Repair and Rebuild>> from the admin module ... but nothing changed in my databe .

    This is the message that the sugarcr raised when i ccliked on the Repair button.

    Rebuilding Audit Tables...
    User not Audit Enabled...

    So my question is:
    how can i add a custom field to the Users module, i want the field to be created in the database, but also viewed and editable through the Web interface when i am updating or adding a user.

    Thanks.

  2. #2
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: custom vardefs.php does not work

    Hi amicky

    Custom vardefs does not work this way, you need to create the file custom/Extension/modules/Users/Ext/Vardefs/vardefs.ext.php instead.
    So you may add a code like that:

    PHP Code:
    $dictionary['User']['fields']['<FieldName>']['<AttributeName>'] = '<AttributeValue>'
    Then you can go to Admin -> Repair -> Rebuild Extension.

    Regards
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  3. #3
    amicky is offline Member
    Join Date
    Oct 2008
    Posts
    12

    Smile Re: custom vardefs.php does not work

    Thanks for your quick and relevant response.

  4. #4
    amicky is offline Member
    Join Date
    Oct 2008
    Posts
    12

    Default Re: custom vardefs.php does not work

    I have one question,

    In the sugarcrm developper guide they suggest this:

    PHP Code:

    <?php
    // 1 to update  
     
    $dictionary['Call']['fields']['parent_type']['vname'] = 'LBL_PARENT_TYPE'
     
    $dictionary['Call']['fields']['parent_id']['vname'] = 'LBL_PARENT_ID';} 
     
    $dictionary['Call']['fields']['deleted']['importable'] = false
     
    // 2 to create a new field

         
    $dictionary['Call'] = array('fields' => array ( 
            
    'related_id' => array ( 
              
    'name' => 'related_id'
              
    'vname' => 'LBL_RELATED_ID'
              
    'type' => 'id'
              
    'required' => false
              
    'reportable' => false
              
    'audited' => true,    
              
    'comment' => 'ID of a related record of this call',  
      ); 
    ?>

    i tried the second one, it sames that the file have been considered by sugar, this is the result of quick buit and repair message:

    Clearing Vardefs from cache...done
    Clearing language files from cache...done
    Repair Database
    Print Print Help Help
    Processing database and vardef comparison...

    Repairing DB for User
    Database tables are synced with vardefs
    Clearing Template files from cache...done
    Clearing JS files from cache...done
    Clearing Vardefs from cache...done
    Clearing JS Language files from cache...done
    Clearing Sugar Dashlet files from cache...done
    Rebuilding Audit Tables...
    User not Audit Enabled...
    Done
    Rebuilding Extensions...
    Rebuilding Language...en_us
    Rebuilding Vardefs...

    Warning: fread() [function.fread]: Length parameter must be greater than 0 in /var/www/SugarCE-Full-5.1.0c/ModuleInstall/ModuleInstaller.php on line 1058
    Rebuilding Layoutdefs...
    Rebuilding Menus...
    Rebuilding User Page Section...
    Rebuilding administration Section...
    Rebuilding Relationships


    But i steel dont see the new field in my database

    thanks

  5. #5
    tbarrault is offline Junior Member
    Join Date
    Dec 2008
    Posts
    1

    Default Re: custom vardefs.php does not work

    Hello,

    I have the same problem...

    I want to set a defaulf value in the field "account name" Cases !
    So i have create this file "vardefs.ext.php" in :
    "website_root"/custom/Extension/modules/Cases/Ext/Vardefs/
    it contains that:
    <?
    $dictionary['Cases']['fields']['account_id']['default'] = 'a42cd34f-f7b9-1614-94c6-46096475d9bc';
    $dictionary['Cases']['fields']['account_name']['default'] = 'service info';
    ?>

    I rebuild with admin repair module...
    But nothing !

    What is the problem ?
    Thanks.

    TB

  6. #6
    amicky is offline Member
    Join Date
    Oct 2008
    Posts
    12

    Default Re: custom vardefs.php does not work

    Hi tbarrault,

    I finaly fixed my problem by adding this code to my :
    custom/Extension/modules/Users/Ext/Vardefs/vardefs.ext.php
    PHP Code:
    <?PHP
    $dictionary
    ['User']['fields']['new_field']=array (
                                                              
    'name' => 'new_field',
                                                              
    'vname' => 'LBL_NEW_FIELD',
                                                              
    'type' => 'varchar',
                                                              
    'required' => false,
                                                              
    'reportable' => false,
                                                              
    'len' => 5,
                                                              );

    ?>
    then i ran <<Quick Repair and Rebuild>> .

    then the system told me that it is altering the DB by adding the new field.
    after that my new field was added to the DB.

    now i am tryying to see if my new field is accessible as an attribute of User bean.
    i will give you a feed back.

    bye.

  7. #7
    SugarDev.net is offline Sugar Community Member
    Join Date
    Feb 2008
    Posts
    1,401

    Default Re: custom vardefs.php does not work

    You guys didn't quite read the whole page of the Developer Guide.. it's located here: http://developers.sugarcrm.com/docs/...uide.1.81.html.

    Mind the part of Master directories...you should never need to edit a ".ext.php" file!!! If you do, next time you rebuild extensions your changes will be lost.

    PHP Code:
    <?php
    $dictionary
    ['Call'] = array('fields' => array (
    Iew, this should be:

    PHP Code:
    <?php
    $dictionary
    ['Call']['fields']['new_field'] = array(
    Developers go here
    Businesses go there (Dutch)

    Modules:
    SugarDev.net Developer Tools | Config | Dutch Language Pack
    "Nothing gets fixed unless there is a bug"

  8. #8
    catnipper is offline Sugar Community Member
    Join Date
    Jul 2008
    Posts
    15

    Question Display related values in listview

    Thanks, I managed to diplay a custom field from Accounts in the Contacts detailed view based on this article. Now I would like to have the same information in the list view.

    This is how I created the field in the custom vardef (Contacts):
    PHP Code:
    $dictionary['Contact']['fields']['area_sales_c']['name'] = 'area_sales_c';
    $dictionary['Contact']['fields']['area_sales_c']['rname'] = 'area_sales_c';
    $dictionary['Contact']['fields']['area_sales_c']['id_name'] = 'account_id';
    $dictionary['Contact']['fields']['area_sales_c']['vname'] = 'LBL_AREA_SALES';
    $dictionary['Contact']['fields']['area_sales_c']['join_name'] = 'accounts';
    $dictionary['Contact']['fields']['area_sales_c']['type'] = 'relate';
    $dictionary['Contact']['fields']['area_sales_c']['link'] = 'accounts';
    $dictionary['Contact']['fields']['area_sales_c']['table'] = 'accounts_cstm';
    $dictionary['Contact']['fields']['area_sales_c']['isnull'] = 'true';
    $dictionary['Contact']['fields']['area_sales_c']['module'] = 'Accounts';
    $dictionary['Contact']['fields']['area_sales_c']['dbType'] = 'varchar';
    $dictionary['Contact']['fields']['area_sales_c']['len'] = '255';
    $dictionary['Contact']['fields']['area_sales_c']['source'] = 'non-db';
    $dictionary['Contact']['fields']['area_sales_c']['unified_search'] = true
    As it seems such fields are not listed inside Studio - therefore I tried to add the field in the custom listviewdefs manually... but either no (empty) value is being showed or the list view does not display at all.

    Somebody can please indicate me the right direction?

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. SOAP - Query custom fields added via vardefs
    By pbrunnen1 in forum Developer Help
    Replies: 2
    Last Post: 2008-10-04, 08:27 PM
  2. vardefs.php versus vardefs.ext.php
    By helpwithasmile in forum Help
    Replies: 1
    Last Post: 2008-02-21, 01:14 PM
  3. Replies: 0
    Last Post: 2008-01-10, 03:42 PM
  4. New custom fields don't work
    By mlh in forum Help
    Replies: 0
    Last Post: 2006-08-23, 02:09 PM
  5. 3.0c - Custom Field still does not work
    By ruchida in forum Help
    Replies: 1
    Last Post: 2005-06-03, 11:17 PM

Tags for this Thread

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
  •