How to create a subpanel in sugarcrm 7.6 in Accounts module.

Hi

   I want to create a subpanel,I have created an custom field-relatedaccount_c(related to accounts module)field in the Calls/Meetings/Tasks modules.This field appears only when the Parent Type="Projects" for the calls/Meetings/Tasks.So in the accounts module i want a Project Activities subpanel in which we can see all the list of calls/meetings/tasks whose parent type is Projects and  relatedaccount_c.Shijin Krishna Gustav Lindström Ajay Kumar

Parents Reply Children
  • Hi Gustav

        As a start up can you please update me something simple.For example like creating the calls subpanel in Accounts or anything simple.

  • Have you tied the package? Installed it? Does it work? You change the content of getCustomJoin function to get another result.

  • public function getRelatedModuleName()

      {

      return 'Calls'; //Here you change linked module

      }

    And in getCustomJoin you change the result

        protected function getCustomJoin($params = array())

        {

      $GLOBALS['log']->fatal('Linkcalls getCustomJoin');

            $bean_id = $this->db->quoted($this->focus->id);

            $sql = " INNER JOIN(";

            $sql .= "SELECT calls_result.id FROM calls as calls_result inner join contacts as contacts_c on calls_result.parent_id = contacts_c.id left join accounts_contacts on contacts_c.id = accounts_contacts.contact_id Where calls_result.parent_type = 'Contacts' and accounts_contacts.account_id = {$bean_id}";

      //$sql .= "SELECT id FROM calls where id = '566cf15c-0fcf-1f5d-86f5-542bb8eda451'"; // This is essentially a select statement that will return a set of ids that you can match with the existing sugar_query

            $sql .= ") calls_result ON calls_result.id = calls.id";

            return $sql;

      //return "";

        }

  • Hi Gustav

        I was able to get the subpanel in the accounts module.

    This was working fine

    protected function getCustomJoin($params = array())

        {

      $GLOBALS['log']->fatal('Linkcalls getCustomJoin');

            $bean_id = $this->db->quoted($this->focus->id);

            $sql = " INNER JOIN(";

            $sql .= "SELECT calls_result.id FROM calls as calls_result

    LEFT JOIN calls_cstm cc ON calls_result.id=cc.id_c

    LEFT JOIN accounts a ON a.id=cc.account_id_c WHERE a.id={$bean_id}";

      //$sql .= "SELECT id FROM calls where id = '566cf15c-0fcf-1f5d-86f5-542bb8eda451'"; // This is essentially a select statement that will return a set of ids that you can match with the existing sugar_query

            $sql .= ") calls_result ON calls_result.id = calls.id";

            return $sql;

      //return "";

        }

    Actually my requirement is

    I have created an custom field-relatedaccount_c(related to accounts module)field in the Calls/Meetings/Tasks modules.This field appears only when the Parent Type="Projects" for the calls/Meetings/Tasks.So in the accounts module i want a Project Activities subpanel in which we can see all the list of calls/meetings/tasks whose parent type is Projects and  relatedaccount_c

    So I want to insert the  query like below  to the getCustomJoin() So that i will get all the records of the calls,meetings and tasks related to the Accounts and parent type is projects in to the subpanel we created

    SELECT c.id FROM calls c

    LEFT JOIN calls_cstm cc ON c.id=cc.id_c AND c.deleted=0

    LEFT JOIN accounts a ON a.id=cc.account_id_c WHERE a.parent_type='P_Projects' AND a.id='4e5da5a4-9281-ab68-9407-5617aec95927'

    UNION ALL

    SELECT m.id FROM meetings m

    LEFT JOIN meetings_cstm mm ON m.id=mm.id_c AND m.deleted=0

    LEFT JOIN accounts ac ON ac.id=mm.account_id_c WHERE m.parent_type='P_Projects' AND ac.id='4e5da5a4-9281-ab68-9407-5617aec95927'

    UNION ALL

    SELECT t.id FROM tasks t

    LEFT JOIN tasks_cstm tt ON t.id=tt.id_c AND t.deleted=0

    LEFT JOIN accounts acc ON acc.id=tt.account_id_c WHERE t.parent_type='P_Projects' AND acc.id='4e5da5a4-9281-ab68-9407-5617aec95927'

  • Hi Gustav

         I want the subpanel so that it contains records from Tasks,Meetings and Calls.

    I have tried

    custom/Extension/modules/Accounts/Ext/Vardefs/your_field_name.php

    <?php

    $dictionary["Account"]["fields"]["your_field_name"] = array(

        'name' => 'all_calls',

        'type' => 'link',

        'link_file' => 'custom/modules/Accounts/LinkCalls.php',

        'link_class' => 'YourNewLink',

        'source' => 'non-db',

        'vname' => 'LBL_NEW_LINK',

        'module' => 'Calls',

        'link_type' => 'many',

        'relationship' => '',

    );

    $dictionary["Account"]["fields"]["your_field_name"] = array(

        'name' => 'all_calls',

        'type' => 'link',

        'link_file' => 'custom/modules/Accounts/LinkCalls.php',

        'link_class' => 'YourNewLink',

        'source' => 'non-db',

        'vname' => 'LBL_NEW_LINK',

        'module' => 'Meetings',

        'link_type' => 'many',

        'relationship' => '',

    );

    $dictionary["Account"]["fields"]["your_field_name"] = array(

        'name' => 'all_calls',

        'type' => 'link',

        'link_file' => 'custom/modules/Accounts/LinkCalls.php',

        'link_class' => 'YourNewLink',

        'source' => 'non-db',

        'vname' => 'LBL_NEW_LINK',

        'module' => 'Tasks',

        'link_type' => 'many',

        'relationship' => '',

    );

    as i need the record from the three modules records in to the same subpanel.But currently it is not working as we require

  • This second query which i have mentioned is also working fine but only the Calls data is getting in to the subpanel

  • I think you have to create one link with all the content, you cant use three links in one subpanel.

  • Hi Gustav

         Or are there is any way we can return three modules to load the data of three modules using

    At custom/modules/Accounts/

    public function getRelatedModuleName()

      {

      return 'Calls';//Is there any thing we can do here in the

      }

  • Hi Gustav

         You mean to say one subpanel for each module to retreive the relatedaccount data.