How to modify Listview of a subpanel?

I can modify Listview of modules by changing the code in include\ListView\ListViewData. If I wanted any column data to show in red color I can do that by changing code of above file. Now, can we do something like it with the subpanel data? I have made a subpanel and want to make phone call column of the subpanel clickable. How can i do it? 

  • Which Sugar version do you use? Which edition?

    You never should modify any core files, like files in the include/... directory, if possible.

    Each such customization should be done in the custom/... directory to creatze upgrade safe customizations.

    The phone numbers are stored in phone fields, so if you look in the definition of these phone fields (e.g. in include/SugarFields/Fields/ (6.x) or clients/base/fields/ (7.x)) you are at the right placeto start with some customizations.
    On the other side there is a so called "SkypeOut®-Integration" option which can be set in admin - system settings which creates a callto:-reference on phone numbers (which is accepted by some other cti integrations too). This feature creates a callto:-reference every time a phone number starts with + or 00 or 011.

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    hkuske@sugarcrm.com
    SugarCRM Deutschland GmbH

  • Offshore Evolution Yes, I am trying process_record. But process_record do not get fired in detail view and subpanels are in detail view. According to docs, process_record Executes when the record is being processed as a part of the ListView or subpanel list. I did not understand what docs meant as part of subpanel list. If it fires on subpanel list then it must fire in the detail view where subpanels are. How can i use process_record to access the subpanel data. Help needed.

  • Yes, I am trying process_record. But process_record do not get fired in detail view and subpanels are in detail view. According to docs, process_record Executes when the record is being processed as a part of the ListView or subpanel list. I did not understand what docs meant as part of subpanel list. If it fires on subpanel list then it must fire in the detail view where subpanels are. How can i use process_record to access the subpanel data. Help needed.

  • Sugar Version 6.5.23 (Build 1061) 

     

    Can I access subpanel data (in detail view) using logic_hooks.

  • As a subpanel view is derived from listview, the process_record hook is called for each visible entry of a subpanel.

    So, if you have a logic_hook function for contacts in custom/modules/Contacts/ContactHook.php 

    <?php
    class ContactHook {
    function CallHook($bean, $event, $arguments){
    $GLOBALS['log']->fatal("ContactHook:".$event."-".$bean->id);
    }
    }
    ?>

    and two logic_hooks for that in custom/modules/Contacts/logic_hooks.php

    $hook_array['after_retrieve'] = Array();
    $hook_array['after_retrieve'][] = Array(1, 'Contacts Hook', 'custom/modules/Contacts/ContactHook.php', 'ContactHook', 'CallHook');

    $hook_array['process_record'] = Array();
    $hook_array['process_record'][] = Array(1, 'Contacts Hook', 'custom/modules/Contacts/ContactHook.php','ContactHook', 'CallHook');

    you get a log entry if you open a single contact and you get log entries for all related contacts if you open a single account because in the account detail view the related contacts are shown in a subpanel which is derived from list view.

    sugarcrm.log  - Detail view of one contact

    11/14/16 18:27:34 [472][1][FATAL] ContactHook:after_retrieve-378981b4-af4e-4c5e-c90d-5829defe1958

    sugarcrm.log - Detail view of one account with 6 related accounts
    11/14/16 18:27:34 [472][1][FATAL] ContactHook:process_record-e14a3ca5-fc77-073f-e049-5829dec5355e
    11/14/16 18:27:34 [472][1][FATAL] ContactHook:process_record-378981b4-af4e-4c5e-c90d-5829defe1958
    11/14/16 18:27:34 [472][1][FATAL] ContactHook:process_record-aa663fce-2dbe-b8ee-1f4d-5829de49911a
    11/14/16 18:27:34 [472][1][FATAL] ContactHook:process_record-5f2a4ea8-b524-b38e-fdfe-5829decdbcbd
    11/14/16 18:27:34 [472][1][FATAL] ContactHook:process_record-40ff6c7b-6e00-54f9-eb5a-5829dedbc114
    11/14/16 18:27:34 [472][1][FATAL] ContactHook:process_record-474901ea-66fe-efb5-b32e-5829de4f6c2d

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    hkuske@sugarcrm.com
    SugarCRM Deutschland GmbH

  • kuske I am new to SugarCRM. The $bean that gets passed is modules(eg: Contact) bean or a subpanel's bean. Or is it something like when i open a submodule (expand) process_records fires again this time loading subpanels's bean. If i do get to maipulate data of subpanels is there anyway I can make a link to external sources in or out of that module. For example I would link all my source from plain text google to clickable google.com. The user will only see google and when he clicks it google opens in new tab. Can I do something like $link="<a href='www.google.com'>".$bean->source"</a>";

    Thank you for explaining the above so well. please clear out this confusion. Whose $bean is accesible when in process_records function.

  • HiTalha Anwar,

    If I wanted any column data to show in red color I can do that by changing code of above file. Now, can we do something like it with the subpanel data?

    Which module have you need?  You have to need this column red color, in this module right process_record logic hook.

    custom/modules/<Module Name>/logic_hook.php

    $hook_array['process_record'] = Array(); 
    $hook_array['process_record'][] = Array(107, 'Display Column Color change in Listview', 'custom/modules/<Module Name>/process_logic_hook.php','OEPL_ClsProcess', 'fn_process');

    custom/modules/<Module Name>/process_logic_hook.php

    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    class OEPL_ClsProcess {

        function fn_process(&$bean, $event, $arguments){
            global $sugar_config;
           
            $bean->change_color_field_name = '<font style="color:red">'.$bean->change_color_field_name.'</font>';
        }
       
    }
    ?>

    Hope helpful

    Regards,

    Dipesh

    Offshore Evolution Pvt Ltd

  • Hi Talha,

    you have two possibilities.

    1) You can use the URL filed type to create a link opening in a new window. So you just open studio, got to fields of contacts module and create a new field of type URL. Here you can generate the URL automatically by setting its values
    Generate URL = set
    Default Value = e.g. "https://www.google.de/?#q={name}"

    Then you can use that field in detail view, list view and subpanels.

    In the UI it looks like "https://www.google.de/?#q=Beverley Laura" and sometimes it will not be calculated and empty (why ever).

    2) You just create a text field in studio and set the value in a after_retrieve and process_record logic hook like that:

    class ContactHook {
       function CallHook(&$bean, $event, $arguments){
          $GLOBALS['log']->fatal("ContactHook:".$event."-".$bean->id);
          $bean->ext_link2_c = '<a href="https://www.google.de/?#q='.$bean->last_name.'" target="_blank">Link to Google</a>';
       }
    }

    And it will look in UI like that Link to Google

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    hkuske@sugarcrm.com
    SugarCRM Deutschland GmbH