BIG ISSUE : Sugar 7 account_contracts relationship not found

Hello everybody,

I came accross a big issue in my SugarPro 7.5.1.

We did not see it, but it seems that my standard relationship between Accounts and Contracts modules is broken.

I still can see it in Studio > Accounts > relationships : account_contracts is a 1-M relationship. And it is unable to edit or delete it since it's a standard. And I still can see it through Studio > Contracts > relationships  too.

When i am in a Contract record, i'm able to see the Account related. And i'm able to click on it and see the Account record. (so the link in that way is well done)

BUT, when i'm in an Account record, in the Contracts subpanel, the link between the contract and the current account is not done. I can see the contract (name, date etc...) in the subpanel. But i can't click on its name and have a redirection on its record.

AND i've searched in my database, and i have no database named "account_contracts".

i've run several QRR and several "Repair relationships" and nothing did the job...

Please could you help me at least to fix it ? Like i don't know, just recreate a table named "account_contracts", rebuild and Bam get it fixed ?

Thanks a lot, it's a pain in my project !
  • It does not look like the accounts_contract table is created by default.  The relationship appears to be stored in the contracts table. 

    I've seen this issue before when the link variable is not set to true.  

    Look to see if you have a file at:

    ./custom/modules/Contracts/clients/base/views/subpanel-for-accounts-contracts/subpanel-for-accounts-contracts.php

    Confirm that the file shows a 'link' => true; variable set.

    You will need to run a Quick Repair & Rebuild within Admin > Repairs if you make any changes.

    Hope this helps.
  • Hi GaelleFernandez,

    Don't worry, nobody has taken your relationship table...:)
    For accounts_contracts relationship we don't have an extra relationship table.If you see contracts table you can see a field account_id.This is same as standard accounts_contacts relationship.

    As  loriarce said you can enable the link parameter for name in the subpanel file.You won't be having the file in the specified path by default.So navigate to Admin>Studio>Accounts>subpanels>contracts
    and do save and deploy, then the file will get generated in the following path automatically.

    ./custom/modules/Contracts/clients/base/views/subpanel-for-accounts-contracts/subpanel-for-accounts-contracts.php 

    Thanks!
  • Hello loriarce,
    First of all, thanks a lot for your answer, it calmed me a little. :)
    Secondly, yes I see a account_id column in Contracts table => I assume this is rendering the link in the subpanel of Account in a Contract record. But no contract_id in Accounts table, could it be the cause of the nolinking in the subpanel for Contracts in Account Record?

    I've tested to add the 
    'link' => true,
    In the subpanel-for-accounts-contracts.php , and ran a QRR, but there is no change.
    Maybe  i've set it all wrong ?
    Could you enlight me, please?

    Secondly, juste a thought i had when modifying this file : it is generated via the studio's layout. So if i change anything via studio, the file will be overwritten, right? Will i always have to modify it after an edit of subpanel layout ?

    Here is the code of my contracts subpanel in account module, stored in ./custom/modules/Contracts/clients/base/views/subpanel-for-accounts-contracts/subpanel-for-accounts-contracts.php 

    <?php
    // created: 2015-07-07 00:52:06
    $viewdefs['Contracts']['base']['view']['subpanel-for-accounts-contracts'] = array (
      'type' => 'subpanel-list',
      'link' => true,
      'panels' => 
      array (
        0 => 
        array (
          'name' => 'panel_header',
          'label' => 'LBL_PANEL_1',
          'fields' => 
          array (
            0 => 
            array (
              'name' => 'name',
              'label' => 'LBL_CONTRACT_NAME',
              'enabled' => true,
              'default' => true,
            ),
            1 => 
            array (
              'name' => 'type_offre_c',
              'label' => 'LBL_TYPE_OFFRE',
              'enabled' => true,
              'default' => true,
            ),
            2 => 
            array (
              'name' => 'produit_c',
              'label' => 'LBL_PRODUIT',
              'enabled' => true,
              'default' => true,
            ),
            3 => 
            array (
              'name' => 'situation_contrat_c',
              'label' => 'LBL_SITUATION_CONTRAT',
              'enabled' => true,
              'default' => true,
            ),
            4 => 
            array (
              'name' => 'modele_c',
              'label' => 'LBL_MODELE',
              'enabled' => true,
              'default' => true,
            ),
            5 => 
            array (
              'name' => 'immatriculation_c',
              'label' => 'LBL_IMMATRICULATION',
              'enabled' => true,
              'default' => true,
            ),
            6 => 
            array (
              'name' => 'ville_mrh_c',
              'label' => 'LBL_VILLE_MRH',
              'enabled' => true,
              'default' => true,
            ),
          ),
        ),
      ),
    );

    Thanks a lot for your kind help !
  • I'm answering my own question with the really kind and reassuring help of loriarce and Shijin Krishna !

    Here is the full / synthetic answer :

    There is no account_contracts table created for the relationship. It is in fact stored in the contracts table under the column account_id.

    To enable the link to the Contracts subpanel in Accounts, first generate the file ./custom/modules/Contracts/clients/base/views/subpanel-for-accounts-contracts/subpanel-for-accounts-contracts.php  by going to Admin>Studio>Acocunts>subpanels>contracts  and save and deploy this view.

    Then, in the subpanel-for-accounts-contracts.php, you'll have the fields visible for this layout. Chose the one you want (but the name field is better generally) and set it like that :
    0 => 
    array (
              'name' => 'name',
              'label' => 'LBL_CONTRACT_NAME',
              'enabled' => true,
              'default' => true,            'link' => true,
            ), 
     
    Then, go to admin > repair > quick repair and rebuild.

    But, be carefull : because this file is generated when changing the view, i don't know if your change will last for ever.

    So, again, thanks a lot to the kind loriarce and Shijin Krishna : they have been very helpful and kind and reassuring me with the big fuss i made out of this problem ! :)
  • Hi loriarce, i finally found where to put the 'link'=>true (see my answer a little down), but i still have this interrogation of : Will the change last if i re-deploy the subpanel layout ?
  • Don't worry, it will persist even after re-deploying the layout.

    Thanks!