Results 1 to 6 of 6

Thread: Howto get Contact PopUp Field

  1. #1
    Nico.awc is offline Junior Member
    Join Date
    Apr 2008
    Posts
    5

    Default Howto get Contact PopUp Field

    Hi all,

    I like to get an additional field from the contact popup and put the data in a custom field in my form.
    So I put the field I like the have (phone_work) and my customfield (contact_phone_c) in the field_to_name_array of open_popup().
    If I select a contact, nothing happns. My custom field stays emty.

    I looked in die Popup-source and found the 'associated_javascript_data' array. There is my PHONE_WORK field but it is empty.

    If I replace phone_work with salutation in the field_to_name_array of open_popup() my custom filed is filled with the salutation, which is also filled in the 'associated_javascript_data' array.

    How do I get PHONE_WORK filled with data, so I can assume it to my custom filed.

    thanks
    Nico

  2. #2
    z3r0 is offline Sugar Community Member
    Join Date
    May 2009
    Posts
    189

    Question Re: Howto get Contact PopUp Field

    Hi,
    have you found a solution for this empty fields in popup source?

  3. #3
    Nico.awc is offline Junior Member
    Join Date
    Apr 2008
    Posts
    5

    Default Re: Howto get Contact PopUp Field

    Hi,

    thats log time ago. If I remember correctly, I patched include/Popups/PopupSmarty.php to fill fields I like to have.

    If you like to have line number or example code please say so. I will try to find the file of this project.

  4. #4
    z3r0 is offline Sugar Community Member
    Join Date
    May 2009
    Posts
    189

    Default Re: Howto get Contact PopUp Field

    example code would be great

    i found out, that if i put the primary address fields to the popup listview, they will be in the associated_javascript_data varialbe, too. but this solution is not nice.

  5. #5
    Nico.awc is offline Junior Member
    Join Date
    Apr 2008
    Posts
    5

    Default Re: Howto get Contact PopUp Field

    OK, it was an old 5.0.0i and is one of my first steps in sugar.
    In include/Popups/PopupSmarty.php arround line 184 should be:

    Code:
    $associated_row_data = array();
    foreach($this->data['data'] as $val){
       $associated_row_data[$val['ID']] = $val;
    }
    I put an sql-select into the foreach construct to get what i want and put the result to the associated_row_data array. So my code looks like

    Code:
    $associated_row_data = array();
    foreach($this->data['data'] as $val){
       $associated_row_data[$val['ID']] = $val;
    
       $link_custom = mysql_connect($GLOBALS['sugar_config']['dbconfig']['db_host_name'], $GLOBALS['sugar_config']['dbconfig']['db_user_name'], $GLOBALS['sugar_config']['dbconfig']['db_password']);
       $db_custom = mysql_select_db($GLOBALS['sugar_config']['dbconfig']['db_name'], $link_custom);
       $sql_custom = "SELECT contacts.phone_work, contacts.phone_fax FROM contacts WHERE contacts.id ='" . $val['ID'] . "'";
       $result_custom = mysql_query($sql_custom,$link_custom);
       if (!$result) {
           echo mysql_error();
       }
       $row_custom = mysql_fetch_assoc($result_custom);
       if ($row_custom['phone_work']) {
         $associated_row_data[$val['ID']]['PHONE_WORK'] = $row_custom['phone_work'];
       } else {
         $associated_row_data[$val['ID']]['PHONE_WORK'] = "";
       }
       if ($row_custom['phone_fax']) {
         $associated_row_data[$val['ID']]['PHONE_FAX'] = $row_custom['phone_fax'];
       } else {
         $associated_row_data[$val['ID']]['PHONE_FAX'] = "";
       }
    
       mysql_close($link_custom);
    }
    I know there are better ways to do sql querys in sugar, but like I say before this was one of my first steps in sugar.
    Maybe there is a better way to solve this problem, but it is ok for me.

  6. #6
    snikwahj is offline Sugar Community Member
    Join Date
    Dec 2007
    Posts
    38

    Default Re: Howto get Contact PopUp Field

    Hi,

    I too have had to get the phone_work field from Contacts into a custom field via the field_to_name_array in the open_popup call.

    The upgrade-safe way to do this is quite straightforward and is handled within the modules/Contacts/metadata/popupdefs.php file. In there you need to modify the 'listviewsdefs' section by adding the field(s) you want to use in the field_to_name_array to the 'related_fields' section of the 'NAME' array. To add in the phone_work field I changed this value to be:
    PHP Code:
    'related_fields' => array('first_name''last_name''salutation''account_name''account_id''phone_work')), 
    and that did the trick. You should also be able to add in other contacts fields to the same effect.

    In order to keep this upgrade safe you simply need to create a copy custom version of this file in: custom/modules/Contacts/metadata/popupdefs.php and edit that.

    Hopefully this will help someone.

    Thanks,

    JH.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 2007-12-12, 04:45 PM
  2. Limit contact popup to chosen Account
    By Tryphan in forum Developer Help
    Replies: 0
    Last Post: 2007-10-29, 11:54 PM
  3. Replies: 5
    Last Post: 2007-04-26, 07:43 PM
  4. Replies: 2
    Last Post: 2005-11-11, 09: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
  •