link field to another entity

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Icodia
    Junior Member
    • Sep 2018
    • 8

    link field to another entity

    Hi and happy new year for all,

    In "account" entity there is a field named "Industry", is linked (maybe not the good term) in the "lead" entity. The customisation made in account entity appear in this field when i go in a lead view.

    I want to do the same for a custom field created in account entity.

    I create my custom field "enum" type in account entity and i dont know how to apply it in lead entity. i try several things and i dont succeed.

    Did someone know a way ?

    Best regards
  • item
    Active Community Member
    • Mar 2017
    • 1476

    #2
    Hello,
    maybe with a little search/correct



    on lead metadata :

    PHP Code:
    "industry": {
    "type": "enum",
    "view": "crm:views/lead/fields/industry",
    "customizationOptionsDisabled": true,
    "default": "",
    "isSorted": true
    }, 
    
    on client/custom...

    PHP Code:
    Espo.define('crm:views/lead/fields/industry', 'views/fields/enum', function (Dep) {
    
    return Dep.extend({
    
    setup: function () {
    this.params.options = this.getMetadata().get('entityDefs.Account.fields. industry.options');
    this.params.translation = 'Account.options.industry';
    
    Dep.prototype.setup.call(this);
    }
    
    });
    
    }); 
    


    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

    Comment

    • Icodia
      Junior Member
      • Sep 2018
      • 8

      #3
      Hello,

      Thank you for quickly response.

      so i try this with no succes.

      in "custom/Espo/Custom/Resources/metadata/entityDefs/Account.json" i have my field

      PHP Code:
      "industrycom": {
      "type": "enum",
      "options": [
      "N.C",
      "..........."
      ],
      "style": {
      "N.C": null,
      "..........": null
      },
      "default": "N.C",
      "isCustom": true
      } 
      

      in "custom/Espo/Custom/Resources/metadata/entityDefs/Lead.json" i add this in the "fields": { ......

      PHP Code:
      "industrycom": {
      "type": "enum",
      "view": "crm:views/lead/fields/industrycom",
      "customizationOptionsDisabled": true,
      "default": "",
      "isSorted": true
      }, 
      

      I create the file "industrycom.js" in folder "client/custom/src/views/lead/fields/"


      PHP Code:
      Espo.define('crm:views/lead/fields/industrycom', 'views/fields/enum', function (Dep) {
      
      return Dep.extend({
      
      setup: function () {
      this.params.options = this.getMetadata().get('entityDefs.Account.fields. industrycom.options');
      this.params.translation = 'Account.options.industrycom';
      
      Dep.prototype.setup.call(this);
      }
      
      });
      
      }); 
      

      then i rebuild and clean the cache

      I didnt see the field "industrycom" in the EntityManager of lead

      Comment

    • Icodia
      Junior Member
      • Sep 2018
      • 8

      #4
      Hi,

      Thank you, it works.

      in "industrycom.js" there was a space in ".get('entityDefs.Account.fields. industrycom.options');".

      I remove it and i see information in the field.

      Comment

      Working...