Announcement

Collapse
No announcement yet.

Adding column to account_contact

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

  • Adding column to account_contact

    Next to the title I want to store a "location" attribute as well, eg:

    ABC Ltd ------------ Representative @ Sales department ----------------- Yulka Dorova
    ABC Ltd ------------ Filial manager @ Customer service --------------- Igor Balin


    What is the preferred (upgrade safe) way to add this attribute to the relation between Accounts and Contacts ?

    Since account_contact is not a real entity, but an "extended" many2many, the regular way of adding it is not available.

    Any advice would be welcome.

  • #2
    /application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json

    See additionalColumns. Replicate the "role" column. You can add your json in custom directory.

    Comment


    • #3
      That works fine, except it is missing in the edit subform.

      Looking at the API call, the role column is part of Accountscolumns.

      How do I add the department in the Accounts panel when editing a Contact?




      ===============

      For those who want to replicate :

      First add a department column in MySQL:

      ALTER TABLE `account_contact` ADD COLUMN `department` VARCHAR(50) ;


      Then following yurikuzn's suggestion.

      Custom/Resources/metadata/Entitydefs/Contact.json

      {
      "fields": {
      "department": {
      "type": "varchar",
      "maxLength": 50,
      "notStorable": true,
      "select": "accountContact.department",
      "orderBy": "accountContact.department {direction}",
      "where": {
      "LIKE": "contact.id IN (SELECT contact_id FROM account_contact WHERE deleted = 0 AND department LIKE {value})",
      "=": "contact.id IN (SELECT contact_id FROM account_contact WHERE deleted = 0 AND department = {value})"
      }
      }
      }
      }



      Now add it to the list as shown when editing an account. You may do that in the interface.

      Custom/Resources/metadata/layouts/Contact/listForAccount.json

      [
      {
      "name": "name",
      "width": 35,
      "link": true
      },
      {
      "name": "accountRole",
      "width": 35,
      "notSortable": true
      },
      {
      "name": "department"
      },
      {
      "name": "emailAddress"
      }
      ]



      Finally add the translation:

      Custom/Resources/i8n/en_US/Contact.json


      {
      "fields": {
      "department": "Department"
      }
      }

      Comment

      Working...
      X