Announcement

Collapse
No announcement yet.

Filtering field options when linked field selected

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

  • Filtering field options when linked field selected

    I try replicate functional from this topic for custom entities:
    Assuming for a custom entity I want to only allow to select/add contacts (hasMany link) for an specific account the user selected in another link field (account).


    When I try select Provider after selecting Provider Type, I don't see filters parametrs like this:
    Click image for larger version

Name:	Screenshot_20180719_121559.png
Views:	421
Size:	8.7 KB
ID:	40575
    But results of filtering is true. What am I doing wrong?

    /client/custom/src/view/service/fields/provider.js
    Code:
    Espo.define('custom:views/service/fields/provider', 'views/fields/link', function (Dep) { 
         return Dep.extend({          getSelectFilters: function () {             if (this.model.get('providerTypeId')) {                 return {                     'providerType': {                         type: 'equals',                         field: 'providerTypeId',                         value: this.model.get('providerTypeId'),                         valueName: this.model.get('providerTypeName')                     }                 };             }         },          getCreateAttributes: function () {             if (this.model.get('providerTypeId')) {                 return {                     providerTypeId: this.model.get('providerTypeId'),                     providerTypeName: this.model.get('providerTypeName')                 }             }         }      });  });
    /custom/Espo/Custom/Resources/metadata/entityDefs/Service.json
    Code:
    {     "fields": {         "providerType": {             "type": "link"         },         "provider": {             "type": "link",             "view": "custom:views/service/fields/provider"         }     } }
    /custom/Espo/Custom/Resources/metadata/entityDefs/Provider.json
    Code:
    {     "fields": {         "providerTypes": {             "type": "linkMultiple",             "layoutDetailDisabled": false,             "layoutListDisabled": true,             "layoutMassUpdateDisabled": false,             "importDisabled": false,             "noLoad": false,             "isCustom": true         },         "providerTypeId": {             "type": "varchar",             "where": {                 "=": "provider.id IN (SELECT provider_id FROM provider_provider_type WHERE deleted = 0 AND provider_type_id = {value})",                 "<>": "provider.id NOT IN (SELECT provider_id FROM provider_provider_type WHERE deleted = 0 AND provider_type_id = {value})",                 "IN": "provider.id IN (SELECT provider_id FROM provider_provider_type WHERE deleted = 0 AND provider_type_id IN {value})",                 "NOT IN": "provider.id NOT IN (SELECT provider_id FROM provider_provider_type WHERE deleted = 0 AND provider_type_id IN {value})",                 "IS NULL": "provider.provider_type_id IS NULL",                 "IS NOT NULL": "provider.provider_type_id IS NOT NULL"             },             "disabled": true         }     },     "links": {         "providerTypes": {             "type": "hasMany",             "relationName": "providerProviderType",             "foreign": "providers",             "entity": "ProviderType",             "audited": false,             "isCustom": true         }     } }
    /custom/Espo/Custom/Resources/metadata/entityDefs/ProviderType.json
    Code:
    {     "fields": {         "providers": {             "type": "linkMultiple",             "layoutDetailDisabled": true,             "layoutListDisabled": true,             "layoutMassUpdateDisabled": true,             "importDisabled": true,             "noLoad": true,             "isCustom": true         }     },     "links": {         "providers": {             "type": "hasMany",             "relationName": "providerProviderType",             "foreign": "providerTypes",             "entity": "Provider",             "audited": false,             "isCustom": true         }     } }
    Assuming for a custom entity I want to only allow to select/add contacts (hasMany link) for an specific account the user selected in another link field (account).
Working...
X