changing an integer field to a relate field

I created a field for "client_id" which exists across all of my modules, however in the calls module, as well as others I need this field to relate to an accounts module field with similar values. Particularly here I am trying to create a subpanel in the accounts module which will search the "client_id" field of the calls module and return results based on it. However it is coming up blank

Any help would be greatly appreciated. 

  • There's a guide to how to create a subpanel from a custom query here - https://developer.sugarcrm.com/2015/05/18/creating-subpanels-with-custom-results-in-sugar-7-5/ 

    In your case, the query (in the accounts module) would be something like:

        protected function getCustomJoin($params = array())
        {
            $sql = " JOIN (";
            $sql .= <<<MYCUSTOMQUERY
    SELECT
        calls.id AS my_custom_id
        FROM
            calls
        WHERE
            calls.deleted = 0
            AND calls.client_id = '{$this->focus->client_id}'
    MYCUSTOMQUERY;

            $sql .= ") calls_to_show ON calls_to_show.my_custom_id = calls.id";
            return $sql;
        }
  • Thank you,

         I am working with sugar C.E. so what I ended up doing was in /custom/extension/application/ext/utils/ I created a get_calls_subpanel.php file containing your query a bit modified to suit my needs of course , and redirected from the /custom/modules/accounts/ext/layoutdefs/calls_accounts_1_accounts.php relationship file by adding:

    'get_subpanel_data' => 'function:get_cc_subpanel',
    'generate_select' => true,
    'function_parameters' => array(
    // File where the above function is defined at
    'import_function_file' => 'custom/application/Ext/Utils/custom_utils.ext.php',
    ),

    which got the job done. Thank you for the direction, it helped quiet a bit. I seem to get stuck on sugar mechanics quiet a bit lol, sql queries, php, java, not so much but the parts that are generic to sugar seem to stump me every once in a while. Like right now I am trying to grab the name field from the accounts module and feed it into the subpanel on quickcreate but I can't seem to get the variable to populate correctly using $bean->name; results in nothing and using $this->bean->name; has no result either. Even though I know that the field has a value it doesn't return one. 

    so in my view.edit.php(i created a copy in a view folder under custom.) I am trying to get it to return a value. I know it returns a value as I am using $this->ss->assign('<my variable name>, "text"); and that shows up on screen, however I cannot seem to grab the value of the field 'name' and have it return. So something like:

    $this->ss->assign('<my variable name>, $this->bean->name);

    doesn't work .

  • Yup, Sugar mechanics can get a bit of getting used to. It has better interfaces in Version 7, but I'm not sure that's something you want to hear.

    Glad it worked out anyway.

  • I would love 7+ but my client wouldn't be willing to fork out the $ and thank you .

  • Well there's a false economy for you. But eh, we all have to work with constraints at times.