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

Parents Reply
  • 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

     

Children
  • 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;
    },
    })