Sugar 7 Contact module record view header add middle name

Hello,

I want to add middle name record view header pane in contact module.

Ramana Raju Santhana Francesca Shiekh Alan Apter

Thanks

Dipesh

Offshore Evolution Pvt Ltd

  • Yes it is working with list view page.

    How does it work with record view and edit record view ?

  • Hi Francesca Shiekh,

    I have already set file, custom/modules/Contacts/clients/base/fields/fullname/fullname.js

    /*
    *  I only wanted to apply this change to the Contacts modules so I put this file in:
    *  custom/modules/Contacts/clients/base/fields/fullname/
    */

    ({
        extendsFrom: 'FullnameField',

        formatMap: {
            'f': 'first_name',
            'l': 'last_name',
            's': 'salutation',
            'm': 'middle_name_c'
        },

        initialize: function(options) {
            // override the name format for this module
            app.user.setPreference('default_locale_name_format', 's f m l');

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

        format: function() {
            var fullname = this.model.attributes.salutation +' '+ this.model.attributes.first_name +' ';
                fullname += this.model.attributes.middle_name_c +' '+ this.model.attributes.last_name;

            return fullname;
        },
    })

    But main issue is this.model.attributes.middle_name_c is blank.

  • I've not tried this myself but I don't think you need to override the format Name Model function, just pass an extra variable to specify the format you want.

    If you look at the app.utils.formatNameModel function in sidecar/src/utils/utils.js

    You will see that you can pass the format you want to override the user format:

      formatNameModel: function(module, data, format) {
          format = format || app.user.getPreference('default_locale_name_format');

    So I would try redefining your format function:

        format: function() {
            var format = 's f m l';
            return app.utils.formatNameModel(this.model.module, this.model.attributes, format);
        },

    The formatNameModel function should do all the work for you based on the format you are passing.

    See if that works.

    In general, to get the attributes' values I use this.model.get('<attribute name>'):

    this.model.get('middle_name_c');

    And to set them use this.model.set('<attribute name>', '<attribute value>');

    this.model.set('middle_name_c', 'Carols'); 

    HTH

    FrancescaS

     

  • You add custom/modules/Contacts/clients/base/fields/fullname/fullname.js

    ({
    extendsFrom: 'FullnameField',
    formatMap: {
    'f': 'first_name',
    'l': 'last_name',
    's': 'salutation',
    'p': 'preferred_name_c',
    'm': 'middle_name_c'
    },
    initialize: function(options) {
    // override the name format for this module
    app.user.setPreference('default_locale_name_format', 's f p m l');
    this._super('initialize', [options]);
    },
    format: function() {
    var fullname = this.model.attributes.salutation +' '+ this.model.attributes.first_name +' ';
    fullname += (!_.isEmpty(this.model.attributes.preferred_name_c)) ? '"'+ this.model.attributes.preferred_name_c +'" ': ' ';
    fullname += this.model.attributes.middle_name_c +' '+ this.model.attributes.last_name;
    return fullname;
    },
    })
  • Hi 

    I have the same issue that @ Offshore Evolution had regarding the "undefined" in the middle name field.

    I have followed your response and done what was said but still having the same issue.

  • Did you remember to add the "middle_name" custom field to the Contacts module? This could explain why it would be showing up as "undefined".

    App Ecosystem @ SugarCRM

  • Offshore Evolution - try the suggestion I gave David Sillah which was to check to make sure you created the "middle_name" custom field for the Contacts module. If it doesn't already exist, then Francesca's example will not work. 

    App Ecosystem @ SugarCRM

  • Hi Matt Marum,

    custom/modules/Contacts/clients/base/fields/fullname/fullname.js

    /*
    *  I only wanted to apply this change to the Contacts modules so I put this file in:
    *  custom/modules/Contacts/clients/base/fields/fullname/
    */

    ({
        extendsFrom: 'FullnameField',

        formatMap: {
            'f': 'first_name',
            'l': 'last_name',
            's': 'salutation',
            'm': 'middle_name_c'
        },

        initialize: function(options) {
            // override the name format for this module
            app.user.setPreference('default_locale_name_format', 's f m l');

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

        format: function() {
            var fullname = this.model.attributes.salutation +' '+ this.model.attributes.first_name +' ';
                fullname += this.model.attributes.middle_name_c +' '+ this.model.attributes.last_name;

            return fullname;
        },
    })
  • hi all,

    really useful information and i was able to add the middle name and 2nd last name in my case as in spain we have 2 last names. everything seems to be working fine. just one bit where i am trying to edit the record within the subpanel or list view using action button next to preview, the columns are not aligned correctly and name field in not expanding with

    additional data points. Same is happening with list view. any suggestions how this could be fixed ?

      Subpanel view name not accommodating middle name