Filter a Link field by foreign variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • joy11
    replied
    You were right. It wasn't reading until I changed it to current-product. I am not getting any errors now and it's closer because something shows up as a filter. It still doesn't act quite like I thought it would.

    I've attached a screenshot of how the filter shows up currently. My enum from accounts is called "type" with label "Account Type". I'm not sure how to reference that value. This is what I have in the vendor.js view for that field.

    getSelectFilters: function () {
    return {
    'accountType': {
    type: 'anyOf',
    value: 'Vendor',
    valueName: this.model.get('accountName'),
    }
    };
    }

    Last edited by joy11; 08-11-2017, 07:08 PM.

    Leave a comment:


  • tanya
    replied
    using current-product instead of currentProduct is important. Check in browser log, if your view was read or you get 404 error

    Leave a comment:


  • joy11
    replied
    I'm sorry, I posted wrong entitydefs above.

    I have this in my custom/Espo/Custom/Resources/metadata/entityDefs/CurrentProducts.json :

    {
    "fields": {
    "vendor": {
    "type": "link",
    "dynamicLogicVisible": null,
    "view": "custom:views/currentProduct/fields/vendor",
    "required": false,
    "audited": false,
    "tooltip": false
    }
    },
    "links": {
    "vendor": {
    "type": "belongsTo",
    "foreign": "vendor",
    "entity": "Account",
    "audited": false,
    "isCustom": true
    }
    }
    }


    this does not work either. I think that my vendor.js isn't quite right? I'm not sure how to write it to only filter and display the accounts with type = "Vendor" (type is an enum added to accounts)

    Leave a comment:


  • tanya
    replied
    Hello

    https://stackoverflow.com/questions/...20526#44820526



    needed path \client\custom\src\views\current-product\fields\vendor.js

    definition
    Code:
    Espo.define('custom:views/current-product/fields/vendor', 'views/fields/link', function (Dep) {
    in entityDefs field view has to be the same as in definition 'custom:views/current-product/fields/vendor'

    Leave a comment:


  • joy11
    started a topic Filter a Link field by foreign variable

    Filter a Link field by foreign variable

    I have a custom entity which has a Many-to-One relationship with the Account Entity. My Account Entity has a custom enum of "type" where I have different kinds of accounts I am keeping track of (i.e. Vendor, Customer, Agency)

    My custom entity has a link to the accounts where I'd like to select only accounts with the "type" of "Vendor". I've attached a screenshot of the select filter I'd like to have, but I'm not sure how to write it so that it works. I'm assuming it's something similar to what I'm working with already?


    I have created a custom view: **This does not work.** \client\custom\src\views\currentProduct\field\vend or.js

    Espo.define('custom:views/currentProduct/fields/vendor', 'views/fields/link', function (Dep) {

    return Dep.extend({

    getSelectFilters: function () {
    return {
    'account.type': {
    type: 'anyOf',
    value: 'Vendor',
    valueName: this.model.get('accountName'),
    }
    };
    }
    });

    });



    I've attached the custom view in custom/Espo/Custom/Resources/metadata/entityDefs/CurrentProduct.json

    {
    "fields": {
    "vendor": {
    "type": "link",
    "dynamicLogicVisible": null,
    "view": "custom:views/contract/fields/product",
    "required": false,
    "audited": false,
    "tooltip": false
    }
    },
    "links": {
    "vendor": {
    "type": "belongsTo",
    "foreign": "vendor",
    "entity": "Account",
    "audited": false,
    "isCustom": true
    }
    }
    }
    Last edited by joy11; 08-11-2017, 01:57 PM.
Working...