Results 1 to 10 of 10

Thread: Manually Add Field to contacts table

  1. #1
    mlh
    mlh is offline Sugar Community Member
    Join Date
    May 2006
    Posts
    19

    Default Manually Add Field to contacts table

    Hi all, I have to manually add a field to the contacts table. There are alot of reasons why this can not be done via custom_fields.

    My issue is, that I have added the field to the contacts table, and I can not get it to show up. I have added this line in vardefs.php

    'field' =>
    array (
    'name' => 'field',
    'vname' => 'LBL_field',
    'type' => 'field',
    'required'=>true,
    'reportable'=>false,
    ),

    The db name in the database is called field. It shows up in the sugar fields, however, it does not populate with the data for the record in the database, it is always blank.

    Michael

  2. #2
    kbrill's Avatar
    kbrill is offline SugarCRM PS Engineer
    Join Date
    Jul 2004
    Location
    St Louis, MO
    Posts
    3,183

    Default Re: Manually Add Field to contacts table

    If you are adding a field manually then you also have to tell the bean about it. You would have to add it to Contact.php and maybe field_arrays.phpas well.
    Kenneth Brill - Help Forum Moderator

    I do not respond to 'Private Messages'. Please email me directly instead

    When asking for help, PLEASE give us your Server Information and Version Numbers as asked for on the 'Post New Message' screen as well as any JavaScript errors shown at the bottom of the browser window.
    Help us Help You

  3. #3
    mlh
    mlh is offline Sugar Community Member
    Join Date
    May 2006
    Posts
    19

    Default Re: Manually Add Field to contacts table

    I have added my field in both Contact.php (under class Contact extends SugarBean {
    )

    I have also added it in field_arrays.php.

    I then rebuilt relationships. It still is not working,

    Any other ideas?

    MIchael

  4. #4
    kbrill's Avatar
    kbrill is offline SugarCRM PS Engineer
    Join Date
    Jul 2004
    Location
    St Louis, MO
    Posts
    3,183

    Default Re: Manually Add Field to contacts table

    Did you try a Repair Databases?
    Kenneth Brill - Help Forum Moderator

    I do not respond to 'Private Messages'. Please email me directly instead

    When asking for help, PLEASE give us your Server Information and Version Numbers as asked for on the 'Post New Message' screen as well as any JavaScript errors shown at the bottom of the browser window.
    Help us Help You

  5. #5
    mlh
    mlh is offline Sugar Community Member
    Join Date
    May 2006
    Posts
    19

    Default Re: Manually Add Field to contacts table

    When I do that I get a sql error....

    Error creating table: repair_table: Query Failed:CREATE TABLE repair_table (id char(36) NOT NULL ,field NOT NULL ,deleted bool DEFAULT '0' NOT NULL ,date_entered datetime NOT NULL ,date_modified datetime NOT NULL ,modified_user_id char(36) ,assigned_user_id char(36) ,created_by char(36) ,salutation varchar(5) ,first_name varchar(100) ,last_name varchar(100) ,lead_source varchar(100) ,title varchar(50) ,department varchar(100) ,reports_to_id char(36) ,birthdate date ,do_not_call varchar(3) DEFAULT '0' ,phone_home varchar(25) ,phone_mobile varchar(25) ,phone_work varchar(25) ,phone_other varchar(25) ,phone_fax varchar(25) ,email1 varchar(100) ,email2 varchar(100) ,assistant varchar(75) ,assistant_phone varchar(25) ,email_opt_out varchar(3) DEFAULT '0' ,primary_address_street varchar(150) ,primary_address_city varchar(100) ,primary_address_state varchar(100) ,primary_address_postalcode varchar(20) ,primary_address_country varchar(100) ,alt_address_street varchar(150) ,alt_address_city varchar(100) ,alt_address_state varchar(100) ,alt_address_postalcode varchar(20) ,alt_address_country varchar(100) ,description longtext ,portal_name varchar(255) ,portal_active bool DEFAULT '0' NOT NULL ,portal_app varchar(255) ,invalid_email bool DEFAULT 0 , PRIMARY KEY (id), KEY idx_cont_last_first (last_name, first_name, deleted), KEY idx_contacts_del_last (deleted, last_name), KEY idx_cont_del_reports (deleted, reports_to_id, last_name), KEY idx_cont_assigned (assigned_user_id), KEY idx_cont_email1 (email1), KEY idx_cont_email2 (email2))::MySQL error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL ,deleted bool DEFAULT '0' NOT NULL ,date_entered datet

    If you look at the query the second field it is working is called field, however it does not say what ti is (varchar,int,etc)

    I think I am getting close,
    Thanks for the help.

    Michael

  6. #6
    kbrill's Avatar
    kbrill is offline SugarCRM PS Engineer
    Join Date
    Jul 2004
    Location
    St Louis, MO
    Posts
    3,183

    Default Re: Manually Add Field to contacts table

    Code:
    'field' =>
    array (
    'name' => 'field',
    'vname' => 'LBL_field',
    'type' => 'varchar',
    'len'=>'254'
    'required'=>true,
    'reportable'=>false,
    ),
    Kenneth Brill - Help Forum Moderator

    I do not respond to 'Private Messages'. Please email me directly instead

    When asking for help, PLEASE give us your Server Information and Version Numbers as asked for on the 'Post New Message' screen as well as any JavaScript errors shown at the bottom of the browser window.
    Help us Help You

  7. #7
    mlh
    mlh is offline Sugar Community Member
    Join Date
    May 2006
    Posts
    19

    Default Re: Manually Add Field to contacts table

    Well it ran now, however the field does not show up. If I go into sugar studio and drag the field (which is under sugar fields) it lets me drag it, but it does not display anything on the form. However, all the other fields do.


    Anyone have any ideas?

  8. #8
    mlh
    mlh is offline Sugar Community Member
    Join Date
    May 2006
    Posts
    19

    Default Re: Manually Add Field to contacts table

    Also, in Contact.php
    I edit:
    function retrieve($id = -1, $encode=true)
    {
    $ret_val = parent::retrieve($id, $encode);

    $this->_create_proper_name_field();
    var_dump($ret_val);
    return $ret_val;
    }


    This function and add in the var_dump. It dumps out the field I am wanting to see.

    Michael

  9. #9
    kbrill's Avatar
    kbrill is offline SugarCRM PS Engineer
    Join Date
    Jul 2004
    Location
    St Louis, MO
    Posts
    3,183

    Default Re: Manually Add Field to contacts table

    Do you have LBL_field in your language file?
    Kenneth Brill - Help Forum Moderator

    I do not respond to 'Private Messages'. Please email me directly instead

    When asking for help, PLEASE give us your Server Information and Version Numbers as asked for on the 'Post New Message' screen as well as any JavaScript errors shown at the bottom of the browser window.
    Help us Help You

  10. #10
    sugarcare is offline Sugar Community Member
    Join Date
    Jan 2006
    Posts
    405

    Default Re: Manually Add Field to contacts table

    make sure your presentation layer (html file) has a tag enclosed in curly braces which is populated in the php file using the assign statement.

Thread Information

Users Browsing this Thread

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

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
  •