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'),
}
};
}
Filter a Link field by foreign variable
Collapse
X
-
using current-product instead of currentProduct is important. Check in browser log, if your view was read or you get 404 errorLeave a comment:
-
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:
-
Hello
https://stackoverflow.com/questions/...20526#44820526
EspoCRM Documentation. Contribute to espocrm/documentation development by creating an account on GitHub.
needed path \client\custom\src\views\current-product\fields\vendor.js
definition
in entityDefs field view has to be the same as in definition 'custom:views/current-product/fields/vendor'Code:Espo.define('custom:views/current-product/fields/vendor', 'views/fields/link', function (Dep) {Leave a comment:
-
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
}
}
}1 PhotoLast edited by joy11; 08-11-2017, 01:57 PM.

Leave a comment: