Custom code after migration from 6 to 7

I did a migration of SugarCrm from 6 to 7.6.1 for my customer, i have lost custom codes. I tried to add custom code but it does'nt work. I added my custom code for field name in account, but nohting happens.

this is my editviewdefs.php:

$viewdefs['Accounts']['EditView'] = array(
    'templateMeta' => array(
                            'form' => array('buttons'=>array('SAVE', 'CANCEL')),
                            'maxColumns' => '2', 
                            'useTabs' => true,
                            'widths' => array(
                                            array('label' => '10', 'field' => '30'),
                                            array('label' => '10', 'field' => '30'),
                                            ),
                            'includes'=> array(
                                            array('file'=>'modules/Accounts/Account.js'),
                                         ),
                           ),
                           
    'panels' => array(
    
      'lbl_account_information' => 
      array (
        array (
          array (
            'name' => 'name',
            'label' => 'LBL_NAME',
            'displayParams' => 
            array (
              'required' => true,
            ),
            'customCode' => '{literal}<script language="javascript">function calcUpperAccount(newValue, form) {

            form.name.value = form.name.value.toUpperCase();
                
            }</script>{/literal}
            
            {if is_null($fields.name.value) || $fields.name.value == ""}{assign var="accountname" value=""}{else}{assign var="accountname" value=$fields.name.value}{/if}

            <input type=\'text\' name=\'name\' id=\'name\' onchange=\'calcUpperAccount(this.value, EditView);\' size=\'30\' maxlength=\'25\'  title=\'\' tabindex=\'3\' value = \'{$accountname}\'>            
            ',
          ),
          array (
            'name' => 'phone_office',
            'label' => 'LBL_PHONE_OFFICE',
          ),
        ),

Idid a quick and repair and ctrl+f5

Can you help me?.

  • In V7 the Account name can be changed to upper-case letters in Studio: Accounts/fields/name:

    Calculated value: On

    Formula: strToUpper($name)

  • Thank you for your help!

    I tested but the filed is now unchangeable, i need the user type anything and after the JS uppser case.

    So, i have few javascript functions and i need to make this in "live", what is wrong with my code?

  • editviewdefs.php is not used by SugarCrm V7 modules. Instead of Edit-/Detail-View in V7 there is the RecordView .

    To extend the RecordView with your js-function calcUpperAccount() at the change-event the following works for me:

    Create file:  custom/modules/Accounts/clients/base/views/record/record.js

    ({

        extendsFrom : 'AccountsRecordView',

        initialize : function (options) {

            this._super('initialize', [options]);

            this.events["change input[name=name]"] = 'calcUpperAccount';

        },

        calcUpperAccount : function () {

            var hname = this.model.get('name');

            if (!_.isEmpty(hname))

            {

                this.model.set('name', hname.toUpperCase());

            }

        }

    })

    But the solution above doesn't work if you edit the Account name in the ListView. An alternative could be to customize the fields of type 'name' for accounts:

    Create file:  custom/modules/Accounts/clients/base/fields/name/name.js

    ({

        plugins : ['EllipsisInline', 'MetadataEventDriven'],

        _render : function () {

            if (this.view.name === 'record' || this.view.name === 'audit') {

                this.def.link = false;

            } else if (this.view.name === 'preview') {

                this.def.link = _.isUndefined(this.def.link) ? true : this.def.link;

            }

            this._super('_render');

        },

        /**

         * Called when formatting the value for display

         */

        format: function(value) {

             value = value.toUpperCase();

             return this._super('format', [value]);

        },

        /**

         * Called when unformatting the value for storage

         */

        unformat: function(value) {

            value = value.toUpperCase();

            return this._super('unformat', [value]);

        }

    })

  • Thanks, you save my life!

    I have tested your first solution but nothing happens, the file is not included by sugarcrm after quick and repair, and i don't know why.

    The second solution works fine without format function, i have an error when i want to create new one. The unformat function is enough to my case.

    Thanks again