Adding new field to addresses

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ConsultMe
    Junior Member
    • Aug 2014
    • 3

    Adding new field to addresses

    The single street address field provided by default is not adequate for our addressing needs so I'm looking to add a second street address field.

    It's easy enough to create the text field in Accounts, but what I cannot see is how to associate that with the aggregate fields "billingAddress" or "shippingAddress" - where do I add my new field to the these?

    Thanks
    Andrew
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    See files:
    client/src/views/fields/address.js
    client/res/templates/fields/address/*

    For experienced developer:

    1. Need to add view parameter to metadata "fields.address"
    Create file custom/Espo/Custom/Resources/metadata/fields/address.json
    PHP Code:
    {
      "view": "Custom:Fields.Address"
    } 
    

    2. Extend existing address field view. Create file client/custom/src/views/fields/address.js

    PHP Code:
    Espo.define('Custom:Views.Fields.Address', 'Views.Fields.Address', function (Dep) {
     
     detailTemplate: 'custom:fields.address.detail',
    
     editTemplate: 'custom:fields.address.edit',
    
    ... OVERRIDEN METHODS ...
    
    }); 
    
    3. Create files:
    client/custom/res/templates/fields/address/detail.tpl
    client/custom/res/templates/fields/address/edit.tpl
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • RGF
      Member
      • Aug 2016
      • 38

      #3
      Steps from 1 to 3 to make it possible to change the view (form) of the address.

      But how to add to the Address some fields, such as house, apartment, etc.?

      Comment

      • RGF
        Member
        • Aug 2016
        • 38

        #4
        It looks like I handled myself.
        It is necessary to add to the file custom\Espo\Custom\Resources\metadata\fields\addre ss.json some lines:
        PHP Code:
        "actualFields":[
            ...........
            "flat",
            "house",
            ...........
        ],
        "fields":{
            ...........
            "flat":{
            "type":"varchar"
            },
            "house":{
            "type":"varchar"
            },
            ...........
        } 
        
        ,
        and add some code to client\custom\src\views\fields\address.js like client\src\views\fields\address.js
        Last edited by RGF; 08-11-2016, 07:52 AM.

        Comment

        • MicKress
          Senior Member
          • Aug 2017
          • 105

          #5
          Hi, did you add only the new fileds to the file in custom folder or all adress fields? I have similar topic with person-name. Regards

          Comment

          Working...