Announcement

Collapse
No announcement yet.

Define accountRole as Enum instead of varchar

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Define accountRole as Enum instead of varchar

    Hi,

    I am trying to make accountRole (Title) as enum/drop down while linking an account.


    This didn't work...
    entityDefs/Contact.json

    Code:
    {
        "fields": {
            "accountRole": {
                "type": "enum",
                "required": true,
                "options": [
                    "",
                    "Type-A",
                    "Type-B",
                    "Type-C",
                    "Type-D"
                ],
                "notStorable": true,
                "layoutDetailDisabled": true,
                "layoutMassUpdateDisabled": true,
                "layoutFiltersDisabled": true,
                "exportDisabled": true,
                "importDisabled": true,
                "view": "crm:views/contact/fields/account-role"
            }
        }
    }
    I haven't made any changes in crm:views/contact/fields/account-role
    Last edited by theBuzzyCoder; 03-15-2018, 06:52 AM.

  • #2

    Hi, "view": "crm:views/contact/fields/account-role" this view extends varchar field view. Change the view
    check client/modules/crm/src/views/contact/fields/opportunity-role.js

    Comment


    • #3
      Thanks tanya .


      This is not working. Is there anything else I need to do other than clear_cache and rebuild

      espocrm/client/modules/crm/src/views/contact/fields/account-role.js

      Code:
      Espo.define('crm:views/contact/fields/account-role', 'views/fields/enum', function (Dep) {
      
          return Dep.extend({
      
              detailTemplate: 'crm:contact/fields/account-role/detail',
      
              listTemplate: 'crm:contact/fields/account-role/detail',
      
              setup: function () {
                  Dep.prototype.setup.call(this);
                  this.listenTo(this.model, 'change:title', function (model, value, o) {
                      this.model.set('accountRole', this.model.get('title'));
                  }, this);
              },
      
              getAttributeList: function () {
                  var list = Dep.prototype.getAttributeList.call(this);
                  list.push('title');
                  return list;
              },
      
              data: function () {
                  var data = Dep.prototype.data.call(this);
      
                  if (this.model.has('accountIsInactive')) {
                      data.accountIsInactive = this.model.get('accountIsInactive');
                  }
                  return data;
              }
          });
      
      });
      Contact.json

      Code:
      {
          "fields": {
               "accountRole": {
                  "type": "enum",
                  "notStorable": true,
                  "options": [
                          "",
                         "Type-A",
                         "Type-B",
                         "Type-C",
                         "Type-D"
                   ],
                  "layoutMassUpdateDisabled": true,
                  "layoutListDisabled": true,
                  "layoutDetailDisabled": true,
                  "view": "crm:views/contact/fields/account-role"
              }
          }
      }
      Is there any way to write this in custom folder. So that I don't modify the original source code
      Last edited by theBuzzyCoder; 03-16-2018, 10:06 AM.

      Comment


      • #4
        you have set temples... varchar templates
        https://www.espocrm.com/documentatio.../custom-views/

        Comment


        • #5
          Hi tanya ,

          This is what I have done. But still no use. Can you please tell me what exactly I have to change.

          And I have looked and tried implementation given in the documentation before asking here!

          Code:
          Espo.define('crm:views/contact/fields/account-role', 'views/fields/enum', function (Dep) {
          
              return Dep.extend({
          
                  setup: function () {
                      Dep.prototype.setup.call(this);
                      this.listenTo(this.model, 'change:title', function (model, value, o) {
                          this.model.set('accountRole', this.model.get('title'));
                      }, this);
                  },
          
                  getAttributeList: function () {
                      var list = Dep.prototype.getAttributeList.call(this);
                      list.push('title');
                      return list;
                  },
          
                  data: function () {
                      var data = Dep.prototype.data.call(this);
          
                      if (this.model.has('accountIsInactive')) {
                          data.accountIsInactive = this.model.get('accountIsInactive');
                      }
                      return data;
                  }
              });
          
          });
          Last edited by theBuzzyCoder; 03-16-2018, 10:56 AM.

          Comment


          • #6
            Hi tanya ,

            Any updates on this?

            Thanks in advance

            Comment

            Working...
            X