How to change email field attribute label on listview ?

Hi Friends

I want to change the email field attribute label on listview .

ex . if my email-id length is greater then 10 then it will be 3 dots (...) and after @gmail.com

like  abcdefghijklmnerwr@gmail.com but i want to show abcdefghij...@gmail.com

 

Can i achieve by override the list.js ? Ramana Raju Santhana

Parents
  • Hi, Mehul Bhandari!

    Tevfik Tümer gives you correct advice. You need extend your /custom/modules/Contacts/clients/base/fields/email/email.js with format method:

    ({
        extendsFrom: 'BaseEmailField',

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

        format: function(value) {
            var value = this._super('format', [value]);

            if (this.action == 'list') {
                //debugger;
                var emailString = '';
                if (_.isArray(value) && value.length > 0) {
                    emailString = value[0].email_address;
                } else {
                    emailString = value;
                }

                if (!_.isUndefined(emailString) && emailString != '') {
                    value[0].email_address = this.formatEmailName(emailString);
                }
            }

            return value;

        },

        formatEmailName: function(email) {
            var emailArray = email.split('@'),
                name = emailArray[0],
                domain = emailArray[1];
            if (name.length > 10) {
                return name.substr(0, 10) + '...@' + domain;
            } else {
                return email;
            }
        }

    });
  • Hi Maksim Nesterenko

    Thanks for reply . its working but when click on that email-id for sending email , its creating problem in sending mail because of 3 dots.

Reply Children
  • Hi Mehul,

    • Use Maksim's solution with following changes;
    •     format: function(value) {
                  .
                  .
                  .
                  }

                  if (!_.isUndefined(emailString) && emailString != '') {
                      value[0]['email_address_formated'] = this.formatEmailName(emailString);
                  }
              }

              return value;

          },
    • Then duplicate ./modules/Contacts/clients/base/fields/email/list.hbs to ./custom/modules/Contacts/clients/base/fields/email/list.hbs
    • Then find the anchor tag and do the following changes in custom/modules/Contacts/clients/base/fields/email/list.hbs
      <a href="javascript:void(0);" data-action="email" data-email-to="{{../email_address}}">{{email_address_formated}}</a>
    • Run Quick Repair and Rebuild

    Best Regards
    Tevfik Tümer
    Developer Support Engineer