Migrating from 6.5 to 7.9 - custom/module/Contacts doesn't work more

Hi,

we performed a migration from 6.5 to 7.9.

Our installation of sugar has a lot of custom modules, and fortunally all of this seems to work fine. The issue that we got instead is in the customization of Contacts module.

In custom/modules/Contacts/ we have a lot of scripts (js and php) that should be loaded in Contacts detail view as defined in custom/module/Contacts/metadata/detailviewdef.php

Here the piece of code where scripts are included:

$viewdefs['Contacts']['DetailView'] = array(
'templateMeta' =>
array(
'includes' =>
array(
0 =>
array(
'file' => 'modules/Leads/Lead.js',
),
1 =>
array(
'file' => 'custom/include/javascript/common.js',
),
2 =>
array(
'file' => 'custom/modules/Contacts/javascript/ContactsCustom.js',
),
3 =>
array(
'file' => 'custom/include/javascript/knockout-3.4.0.js',
),
4 =>
array(
'file' => 'custom/modules/Contacts/javascript/ContactsCustomApp.js',
),
5 =>
array(
'file' => 'custom/modules/Contacts/javascript/ContactsCustomViewModel.js',
),
6 =>
array(
'file' => 'custom/modules/Contacts/javascript/ContactsCustomModel.js',
),
),
...

According to http://support.sugarcrm.com/Knowledge_Base/Installation_Upgrade/Migrating_from_Sugar_6.x_to_7/#Metadata I have appended this piece of detailviewdef.php in clients/base/views/record/record.php but scripts are not loaded.

Can someone help me?

  • In my experience, the move from 6.x to 7.x was fundamentally a rewrite of most if not all customizations, logic hooks being the possible exception.

    You will need to move your javascript to an extension of the record and create views: custom/modules/Contacts/clients/base/view/record/record.js and custom/modules/Contacts/clients/base/view/create/create.js

    Here is an example of a record view controller on Cases where something happens when the case_primary_contact_c field is changed.

    ({
      extendsFrom: 'RecordView',
      //always include the initialize
      initialize: function(options){
          this._super('initialize', [options]); //always include this
          this.model.once('sync', function() { //this ensures that your current record values are fully loaded before this takes effect
            this.model.on('change:case_primary_contact_c', this.selectAccount, this);
          }, this);
      },
      selectAccount: function(){
        var primary_contact = this.model.get('case_primary_contact_c') //gets me the value of set for that field
        //do something here with that new value
      }
      //always include the dispose.
       _dispose: function() {
         this._super('_dispose');
       },
    })

    There is no easy way to tell you exactly what to do without knowing more about the individual scripts included and what they are trying to achieve.

    I always find it useful to try to reverse engineer the base views to get a sense of how things are done...

    7.x will take some getting used to, but it's worth it in the end.

    You can start by looking at:

    clients/base/view/record/record.js

    clients/base/view/create/create.js

    There is a thread that was started 2 years ago when a group of us was exactly where you are now. Lost.

    SugarCRM v7 learning resources - Share yours 

    Some things have changed since then, but you will find some links and comments that may help you get started.

    Hope this helps.

    FrancescaS

  • Thank you very much Francesca, I found very useful your answer.

    So let's dirty our hands and start coding

    Have a nice day,

    Adriano